state
stringlengths
0
159k
srcUpToTactic
stringlengths
387
167k
nextTactic
stringlengths
3
9k
declUpToTactic
stringlengths
22
11.5k
declId
stringlengths
38
95
decl
stringlengths
16
1.89k
file_tag
stringlengths
17
73
case inr α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ✝ : Nontrivial α s : Set α := {x | ∃ y, x ⋖ y} y : α → α hy : ∀ x ∈ s, x ⋖ y x Hy : ∀ (x z : α), x ∈ s → z < y x → z ≤ x a : Set α ha : IsOpen a t : Set α := {x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x} z : α → α hz : ∀ x ∈ t, z x < x h'z : ∀ x ∈ t, Ioc (z x) x ⊆ a x : α xt : x ∈ t x' : α x't : x' ∈ t hxx' : x ≠ x' h' : x' < x u : α ux : u ∈ (fun x => Ioc (z x) x) x ux' : u ∈ (fun x => Ioc (z x) x) x' H : x < y x' ⊢ False
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H
exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h')
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H
Mathlib.Topology.Order.Basic.1338_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y }
Mathlib_Topology_Order_Basic
case H α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ✝ : Nontrivial α s : Set α := {x | ∃ y, x ⋖ y} y : α → α hy : ∀ x ∈ s, x ⋖ y x Hy : ∀ (x z : α), x ∈ s → z < y x → z ≤ x a : Set α ha : IsOpen a t : Set α := {x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x} z : α → α hz : ∀ x ∈ t, z x < x h'z : ∀ x ∈ t, Ioc (z x) x ⊆ a this : PairwiseDisjoint t fun x => Ioc (z x) x ⊢ Set.Countable {x | x ∈ {x | ∃ y, x ⋖ y} ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h')
refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h')
Mathlib.Topology.Order.Basic.1338_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y }
Mathlib_Topology_Order_Basic
case H α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ✝ : Nontrivial α s : Set α := {x | ∃ y, x ⋖ y} y : α → α hy : ∀ x ∈ s, x ⋖ y x Hy : ∀ (x z : α), x ∈ s → z < y x → z ≤ x a : Set α ha : IsOpen a t : Set α := {x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x} z : α → α hz : ∀ x ∈ t, z x < x h'z : ∀ x ∈ t, Ioc (z x) x ⊆ a this : PairwiseDisjoint t fun x => Ioc (z x) x x : α hx : x ∈ t ⊢ IsOpen (Ioc (z x) x)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩
suffices H : Ioc (z x) x = Ioo (z x) (y x)
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩
Mathlib.Topology.Order.Basic.1338_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y }
Mathlib_Topology_Order_Basic
case H α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ✝ : Nontrivial α s : Set α := {x | ∃ y, x ⋖ y} y : α → α hy : ∀ x ∈ s, x ⋖ y x Hy : ∀ (x z : α), x ∈ s → z < y x → z ≤ x a : Set α ha : IsOpen a t : Set α := {x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x} z : α → α hz : ∀ x ∈ t, z x < x h'z : ∀ x ∈ t, Ioc (z x) x ⊆ a this : PairwiseDisjoint t fun x => Ioc (z x) x x : α hx : x ∈ t H : Ioc (z x) x = Ioo (z x) (y x) ⊢ IsOpen (Ioc (z x) x)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) ·
rw [H]
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) ·
Mathlib.Topology.Order.Basic.1338_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y }
Mathlib_Topology_Order_Basic
case H α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ✝ : Nontrivial α s : Set α := {x | ∃ y, x ⋖ y} y : α → α hy : ∀ x ∈ s, x ⋖ y x Hy : ∀ (x z : α), x ∈ s → z < y x → z ≤ x a : Set α ha : IsOpen a t : Set α := {x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x} z : α → α hz : ∀ x ∈ t, z x < x h'z : ∀ x ∈ t, Ioc (z x) x ⊆ a this : PairwiseDisjoint t fun x => Ioc (z x) x x : α hx : x ∈ t H : Ioc (z x) x = Ioo (z x) (y x) ⊢ IsOpen (Ioo (z x) (y x))
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H]
exact isOpen_Ioo
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H]
Mathlib.Topology.Order.Basic.1338_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y }
Mathlib_Topology_Order_Basic
case H α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ✝ : Nontrivial α s : Set α := {x | ∃ y, x ⋖ y} y : α → α hy : ∀ x ∈ s, x ⋖ y x Hy : ∀ (x z : α), x ∈ s → z < y x → z ≤ x a : Set α ha : IsOpen a t : Set α := {x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x} z : α → α hz : ∀ x ∈ t, z x < x h'z : ∀ x ∈ t, Ioc (z x) x ⊆ a this : PairwiseDisjoint t fun x => Ioc (z x) x x : α hx : x ∈ t ⊢ Ioc (z x) x = Ioo (z x) (y x)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo
exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo
Mathlib.Topology.Order.Basic.1338_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y }
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ⊢ Set.Countable {x | ∃ y, x < y ∧ Ioo x y = ∅}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by
simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by
Mathlib.Topology.Order.Basic.1380_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ }
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ⊢ Set.Countable {x | ∃ y, y ⋖ x}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by
convert countable_setOf_covby_right (α := αᵒᵈ) using 5
/-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by
Mathlib.Topology.Order.Basic.1388_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x }
Mathlib_Topology_Order_Basic
case h.e'_2.h.h.e'_2.h.h.h.e'_2.h.h.a α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α e_1✝ : α = αᵒᵈ x✝¹ x✝ : α ⊢ x✝ ⋖ x✝¹ ↔ x✝¹ ⋖ x✝
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5
exact toDual_covby_toDual_iff.symm
/-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5
Mathlib.Topology.Order.Basic.1388_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x }
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ⊢ Set.Countable {x | ∃ y < x, Ioo y x = ∅}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by
simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left
/-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by
Mathlib.Topology.Order.Basic.1395_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ }
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ⊢ Set.Countable {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/
nontriviality β
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β ⊢ Set.Countable {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β
have : Nonempty α := Nonempty.map f (by infer_instance)
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β ⊢ Nonempty β
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by
infer_instance
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α ⊢ Set.Countable {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance)
let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance)
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} ⊢ Set.Countable {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this✝ : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} this : ∀ x ∈ s, ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y ⊢ Set.Countable {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`.
choose! z hz using this
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`.
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y ⊢ Set.Countable {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this
have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y ⊢ InjOn f s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by
apply StrictMonoOn.injOn
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
case H α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y ⊢ StrictMonoOn f s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn
intro x hx y _ hxy
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
case H α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y x : β hx : x ∈ s y : β x✝ : y ∈ s hxy : x < y ⊢ f x < f y
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy
calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s ⊢ Set.Countable {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable.
have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable.
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s ⊢ Set.Countable (f '' s)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by
have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1)
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s ⊢ PairwiseDisjoint (f '' s) fun x => Ioo x (z (invFunOn f s x))
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by
rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
case intro.intro.intro.intro α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s u : β us : u ∈ s v : β vs : v ∈ s huv : f u ≠ f v ⊢ (Disjoint on fun x => Ioo x (z (invFunOn f s x))) (f u) (f v)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv
wlog hle : u ≤ v generalizing u v
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
case intro.intro.intro.intro.inr α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this✝ : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s u : β us : u ∈ s v : β vs : v ∈ s huv : f u ≠ f v this : ∀ u ∈ s, ∀ v ∈ s, f u ≠ f v → u ≤ v → (Disjoint on fun x => Ioo x (z (invFunOn f s x))) (f u) (f v) hle : ¬u ≤ v ⊢ (Disjoint on fun x => Ioo x (z (invFunOn f s x))) (f u) (f v)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v ·
exact (this v vs u us huv.symm (le_of_not_le hle)).symm
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v ·
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s u : β us : u ∈ s v : β vs : v ∈ s huv : f u ≠ f v hle : u ≤ v ⊢ (Disjoint on fun x => Ioo x (z (invFunOn f s x))) (f u) (f v)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm
have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv)
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s u : β us : u ∈ s v : β vs : v ∈ s huv : f u ≠ f v hle : u ≤ v hlt : u < v ⊢ (Disjoint on fun x => Ioo x (z (invFunOn f s x))) (f u) (f v)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv)
apply disjoint_iff_forall_ne.2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv)
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s u : β us : u ∈ s v : β vs : v ∈ s huv : f u ≠ f v hle : u ≤ v hlt : u < v ⊢ ∀ ⦃a : α⦄, a ∈ (fun x => Ioo x (z (invFunOn f s x))) (f u) → ∀ ⦃b : α⦄, b ∈ (fun x => Ioo x (z (invFunOn f s x))) (f v) → a ≠ b
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2
rintro a ha b hb rfl
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s u : β us : u ∈ s v : β vs : v ∈ s huv : f u ≠ f v hle : u ≤ v hlt : u < v a : α ha : a ∈ (fun x => Ioo x (z (invFunOn f s x))) (f u) hb : a ∈ (fun x => Ioo x (z (invFunOn f s x))) (f v) ⊢ False
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl
simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s u : β us : u ∈ s v : β vs : v ∈ s huv : f u ≠ f v hle : u ≤ v hlt : u < v a : α ha : a ∈ Ioo (f u) (z u) hb : a ∈ Ioo (f v) (z v) ⊢ False
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb
exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1)
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s A : PairwiseDisjoint (f '' s) fun x => Ioo x (z (invFunOn f s x)) ⊢ Set.Countable (f '' s)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1)
apply Set.PairwiseDisjoint.countable_of_Ioo A
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1)
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s A : PairwiseDisjoint (f '' s) fun x => Ioo x (z (invFunOn f s x)) ⊢ ∀ x ∈ f '' s, x < z (invFunOn f s x)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A
rintro _ ⟨y, ys, rfl⟩
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
case intro.intro α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s A : PairwiseDisjoint (f '' s) fun x => Ioo x (z (invFunOn f s x)) y : β ys : y ∈ s ⊢ f y < z (invFunOn f s (f y))
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩
simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : LinearOrder β f : β → α inst✝ : SecondCountableTopology α ✝ : Nontrivial β this : Nonempty α s : Set β := {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y} z : β → α hz : ∀ x ∈ s, f x < z x ∧ ∀ (y : β), x < y → z x ≤ f y I : InjOn f s fs_count : Set.Countable (f '' s) ⊢ Set.Countable {x | ∃ z, f x < z ∧ ∀ (y : β), x < y → z ≤ f y}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1
exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1
Mathlib.Topology.Order.Basic.1414_0.Npdof1X5b8sCkZ2
/-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y}
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ⊢ IsCountablyGenerated atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by
by_cases h : ∃ (x : α), IsTop x
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case pos α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ∃ x, IsTop x ⊢ IsCountablyGenerated atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x ·
rcases h with ⟨x, hx⟩
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x ·
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case pos.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α x : α hx : IsTop x ⊢ IsCountablyGenerated atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩
rw [atTop_eq_pure_of_isTop hx]
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case pos.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α x : α hx : IsTop x ⊢ IsCountablyGenerated (pure x)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx]
exact isCountablyGenerated_pure x
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx]
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case neg α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x ⊢ IsCountablyGenerated atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x ·
rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x ·
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case neg.intro.intro.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b ⊢ IsCountablyGenerated atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩
have : Countable b := by exact Iff.mpr countable_coe_iff b_count
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b ⊢ Countable ↑b
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by
exact Iff.mpr countable_coe_iff b_count
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case neg.intro.intro.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b ⊢ IsCountablyGenerated atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count
have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b ⊢ ∀ (s : ↑b), ∃ x, x ∈ ↑s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by
intro s
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b s : ↑b ⊢ ∃ x, x ∈ ↑s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s
have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b s : ↑b ⊢ ↑s ≠ ∅
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by
intro H
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b s : ↑b H : ↑s = ∅ ⊢ False
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H
apply b_ne
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b s : ↑b H : ↑s = ∅ ⊢ ∅ ∈ b
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne
convert s.2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case h.e'_4 α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b s : ↑b H : ↑s = ∅ ⊢ ∅ = ↑s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2
exact H.symm
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this✝ : Countable ↑b s : ↑b this : ↑s ≠ ∅ ⊢ ∃ x, x ∈ ↑s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm
exact Iff.mp nmem_singleton_empty this
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case neg.intro.intro.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b A : ∀ (s : ↑b), ∃ x, x ∈ ↑s ⊢ IsCountablyGenerated atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this
choose a ha using A
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case neg.intro.intro.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s ⊢ IsCountablyGenerated atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A
have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J)
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s ⊢ atTop = generate (Ici '' range a)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by
apply atTop_eq_generate_of_not_bddAbove
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case hs α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s ⊢ ¬BddAbove (range a)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove
intro ⟨x, hx⟩
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case hs α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s x : α hx : x ∈ upperBounds (range a) ⊢ False
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩
simp only [IsTop, not_exists, not_forall, not_le] at h
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case hs α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s x : α hx : x ∈ upperBounds (range a) h : ∀ (x : α), ∃ x_1, x < x_1 ⊢ False
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h
rcases h x with ⟨y, hy⟩
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case hs.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s x : α hx : x ∈ upperBounds (range a) h : ∀ (x : α), ∃ x_1, x < x_1 y : α hy : x < y ⊢ False
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩
obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case hs.intro.intro.intro.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s x : α hx : x ∈ upperBounds (range a) h : ∀ (x : α), ∃ x_1, x < x_1 y : α hy : x < y s : Set α sb : s ∈ b hs : s ⊆ Ioi x ⊢ False
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi
have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _)
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case hs.intro.intro.intro.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s x : α hx : x ∈ upperBounds (range a) h : ∀ (x : α), ∃ x_1, x < x_1 y : α hy : x < y s : Set α sb : s ∈ b hs : s ⊆ Ioi x I : a { val := s, property := sb } ≤ x ⊢ False
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _)
have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩)
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _)
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case hs.intro.intro.intro.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s x : α hx : x ∈ upperBounds (range a) h : ∀ (x : α), ∃ x_1, x < x_1 y : α hy : x < y s : Set α sb : s ∈ b hs : s ⊆ Ioi x I : a { val := s, property := sb } ≤ x J : x < a { val := s, property := sb } ⊢ False
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩)
exact lt_irrefl _ (I.trans_lt J)
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩)
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case neg.intro.intro.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this✝ : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s this : atTop = generate (Ici '' range a) ⊢ IsCountablyGenerated atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J)
rw [this]
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J)
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
case neg.intro.intro.intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α h : ¬∃ x, IsTop x b : Set (Set α) b_count : Set.Countable b b_ne : ∅ ∉ b hb : IsTopologicalBasis b this✝ : Countable ↑b a : ↑b → α ha : ∀ (s : ↑b), a s ∈ ↑s this : atTop = generate (Ici '' range a) ⊢ IsCountablyGenerated (generate (Ici '' range a))
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this]
exact ⟨_, (countable_range _).image _, rfl⟩
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this]
Mathlib.Topology.Order.Basic.1468_0.Npdof1X5b8sCkZ2
instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α)
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁷ : TopologicalSpace α inst✝⁶ : LinearOrder α inst✝⁵ : OrderTopology α ι : Type u_1 π : ι → Type u_2 inst✝⁴ : Finite ι inst✝³ : (i : ι) → LinearOrder (π i) inst✝² : (i : ι) → TopologicalSpace (π i) inst✝¹ : ∀ (i : ι), OrderTopology (π i) a b x : (i : ι) → π i a' b' x' : ι → α inst✝ : Nonempty ι ha : ∀ (i : ι), x i < a i ⊢ Iio a ∈ 𝓝 x
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by
refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a)
theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by
Mathlib.Topology.Order.Basic.1541_0.Npdof1X5b8sCkZ2
theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁷ : TopologicalSpace α inst✝⁶ : LinearOrder α inst✝⁵ : OrderTopology α ι : Type u_1 π : ι → Type u_2 inst✝⁴ : Finite ι inst✝³ : (i : ι) → LinearOrder (π i) inst✝² : (i : ι) → TopologicalSpace (π i) inst✝¹ : ∀ (i : ι), OrderTopology (π i) a b x : (i : ι) → π i a' b' x' : ι → α inst✝ : Nonempty ι ha : ∀ (i : ι), x i < a i i : ι x✝ : i ∈ univ ⊢ Iio (a i) ∈ 𝓝 (x i)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a)
exact Iio_mem_nhds (ha i)
theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a)
Mathlib.Topology.Order.Basic.1541_0.Npdof1X5b8sCkZ2
theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁷ : TopologicalSpace α inst✝⁶ : LinearOrder α inst✝⁵ : OrderTopology α ι : Type u_1 π : ι → Type u_2 inst✝⁴ : Finite ι inst✝³ : (i : ι) → LinearOrder (π i) inst✝² : (i : ι) → TopologicalSpace (π i) inst✝¹ : ∀ (i : ι), OrderTopology (π i) a b x : (i : ι) → π i a' b' x' : ι → α inst✝ : Nonempty ι ha : ∀ (i : ι), a i < x i hb : ∀ (i : ι), x i < b i ⊢ Ioc a b ∈ 𝓝 x
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by
refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b)
theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by
Mathlib.Topology.Order.Basic.1558_0.Npdof1X5b8sCkZ2
theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁷ : TopologicalSpace α inst✝⁶ : LinearOrder α inst✝⁵ : OrderTopology α ι : Type u_1 π : ι → Type u_2 inst✝⁴ : Finite ι inst✝³ : (i : ι) → LinearOrder (π i) inst✝² : (i : ι) → TopologicalSpace (π i) inst✝¹ : ∀ (i : ι), OrderTopology (π i) a b x : (i : ι) → π i a' b' x' : ι → α inst✝ : Nonempty ι ha : ∀ (i : ι), a i < x i hb : ∀ (i : ι), x i < b i i : ι x✝ : i ∈ univ ⊢ Ioc (a i) (b i) ∈ 𝓝 (x i)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b)
exact Ioc_mem_nhds (ha i) (hb i)
theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b)
Mathlib.Topology.Order.Basic.1558_0.Npdof1X5b8sCkZ2
theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁷ : TopologicalSpace α inst✝⁶ : LinearOrder α inst✝⁵ : OrderTopology α ι : Type u_1 π : ι → Type u_2 inst✝⁴ : Finite ι inst✝³ : (i : ι) → LinearOrder (π i) inst✝² : (i : ι) → TopologicalSpace (π i) inst✝¹ : ∀ (i : ι), OrderTopology (π i) a b x : (i : ι) → π i a' b' x' : ι → α inst✝ : Nonempty ι ha : ∀ (i : ι), a i < x i hb : ∀ (i : ι), x i < b i ⊢ Ico a b ∈ 𝓝 x
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by
refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b)
theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by
Mathlib.Topology.Order.Basic.1567_0.Npdof1X5b8sCkZ2
theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁷ : TopologicalSpace α inst✝⁶ : LinearOrder α inst✝⁵ : OrderTopology α ι : Type u_1 π : ι → Type u_2 inst✝⁴ : Finite ι inst✝³ : (i : ι) → LinearOrder (π i) inst✝² : (i : ι) → TopologicalSpace (π i) inst✝¹ : ∀ (i : ι), OrderTopology (π i) a b x : (i : ι) → π i a' b' x' : ι → α inst✝ : Nonempty ι ha : ∀ (i : ι), a i < x i hb : ∀ (i : ι), x i < b i i : ι x✝ : i ∈ univ ⊢ Ico (a i) (b i) ∈ 𝓝 (x i)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b)
exact Ico_mem_nhds (ha i) (hb i)
theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b)
Mathlib.Topology.Order.Basic.1567_0.Npdof1X5b8sCkZ2
theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁷ : TopologicalSpace α inst✝⁶ : LinearOrder α inst✝⁵ : OrderTopology α ι : Type u_1 π : ι → Type u_2 inst✝⁴ : Finite ι inst✝³ : (i : ι) → LinearOrder (π i) inst✝² : (i : ι) → TopologicalSpace (π i) inst✝¹ : ∀ (i : ι), OrderTopology (π i) a b x : (i : ι) → π i a' b' x' : ι → α inst✝ : Nonempty ι ha : ∀ (i : ι), a i < x i hb : ∀ (i : ι), x i < b i ⊢ Ioo a b ∈ 𝓝 x
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by
refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b)
theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by
Mathlib.Topology.Order.Basic.1576_0.Npdof1X5b8sCkZ2
theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁷ : TopologicalSpace α inst✝⁶ : LinearOrder α inst✝⁵ : OrderTopology α ι : Type u_1 π : ι → Type u_2 inst✝⁴ : Finite ι inst✝³ : (i : ι) → LinearOrder (π i) inst✝² : (i : ι) → TopologicalSpace (π i) inst✝¹ : ∀ (i : ι), OrderTopology (π i) a b x : (i : ι) → π i a' b' x' : ι → α inst✝ : Nonempty ι ha : ∀ (i : ι), a i < x i hb : ∀ (i : ι), x i < b i i : ι x✝ : i ∈ univ ⊢ Ioo (a i) (b i) ∈ 𝓝 (x i)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b)
exact Ioo_mem_nhds (ha i) (hb i)
theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b)
Mathlib.Topology.Order.Basic.1576_0.Npdof1X5b8sCkZ2
theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : NoMaxOrder α x : α ⊢ Disjoint (𝓝 x) atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by
rcases exists_gt x with ⟨y, hy : x < y⟩
theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by
Mathlib.Topology.Order.Basic.1587_0.Npdof1X5b8sCkZ2
theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop
Mathlib_Topology_Order_Basic
case intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : NoMaxOrder α x y : α hy : x < y ⊢ Disjoint (𝓝 x) atTop
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩
refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y)
theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩
Mathlib.Topology.Order.Basic.1587_0.Npdof1X5b8sCkZ2
theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop
Mathlib_Topology_Order_Basic
case intro α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : NoMaxOrder α x y : α hy : x < y ⊢ Disjoint (Iio y) {b | y ≤ b}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y)
exact disjoint_left.mpr fun z => not_le.2
theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y)
Mathlib.Topology.Order.Basic.1587_0.Npdof1X5b8sCkZ2
theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α ⊢ TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by
tfae_have 1 ↔ 2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_1_iff_2 α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α ⊢ s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 ·
rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab]
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 ·
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a ⊢ TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab]
tfae_have 1 ↔ 3
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab]
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_1_iff_3 α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a ⊢ s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 ·
rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab]
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 ·
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a ⊢ TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab]
tfae_have 4 → 5
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab]
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_4_to_5 α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a ⊢ (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 ·
exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 ·
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s ⊢ TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩
tfae_have 5 → 1
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_5_to_1 α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s ⊢ (∃ u ∈ Ioi a, Ioo a u ⊆ s) → s ∈ 𝓝[>] a
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 ·
rintro ⟨u, hau, hu⟩
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 ·
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_5_to_1.intro.intro α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s u : α hau : u ∈ Ioi a hu : Ioo a u ⊆ s ⊢ s ∈ 𝓝[>] a
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩
exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s tfae_5_to_1 : (∃ u ∈ Ioi a, Ioo a u ⊆ s) → s ∈ 𝓝[>] a ⊢ TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu
tfae_have 1 → 4
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_1_to_4 α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s tfae_5_to_1 : (∃ u ∈ Ioi a, Ioo a u ⊆ s) → s ∈ 𝓝[>] a ⊢ s ∈ 𝓝[>] a → ∃ u ∈ Ioc a b, Ioo a u ⊆ s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 ·
intro h
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 ·
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_1_to_4 α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s tfae_5_to_1 : (∃ u ∈ Ioi a, Ioo a u ⊆ s) → s ∈ 𝓝[>] a h : s ∈ 𝓝[>] a ⊢ ∃ u ∈ Ioc a b, Ioo a u ⊆ s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h
rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_1_to_4.intro.intro α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s tfae_5_to_1 : (∃ u ∈ Ioi a, Ioo a u ⊆ s) → s ∈ 𝓝[>] a h : s ∈ 𝓝[>] a v : Set α va : v ∈ 𝓝 a hv : v ∩ Ioi a ⊆ s ⊢ ∃ u ∈ Ioc a b, Ioo a u ⊆ s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩
rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_1_to_4.intro.intro.intro.intro α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s tfae_5_to_1 : (∃ u ∈ Ioi a, Ioo a u ⊆ s) → s ∈ 𝓝[>] a h : s ∈ 𝓝[>] a v : Set α va : v ∈ 𝓝 a hv : v ∩ Ioi a ⊆ s u : α au : u ∈ Ioc a b hu : Ico a u ⊆ v ⊢ ∃ u ∈ Ioc a b, Ioo a u ⊆ s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩
refine' ⟨u, au, fun x hx => _⟩
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_1_to_4.intro.intro.intro.intro α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s tfae_5_to_1 : (∃ u ∈ Ioi a, Ioo a u ⊆ s) → s ∈ 𝓝[>] a h : s ∈ 𝓝[>] a v : Set α va : v ∈ 𝓝 a hv : v ∩ Ioi a ⊆ s u : α au : u ∈ Ioc a b hu : Ico a u ⊆ v x : α hx : x ∈ Ioo a u ⊢ x ∈ s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩
refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
case tfae_1_to_4.intro.intro.intro.intro α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s tfae_5_to_1 : (∃ u ∈ Ioi a, Ioo a u ⊆ s) → s ∈ 𝓝[>] a h : s ∈ 𝓝[>] a v : Set α va : v ∈ 𝓝 a hv : v ∩ Ioi a ⊆ s u : α au : u ∈ Ioc a b hu : Ico a u ⊆ v x : α hx : x ∈ Ioo a u ⊢ x ∈ Ioi a
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩
exact hx.1
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a b : α hab : a < b s : Set α tfae_1_iff_2 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioc a b] a tfae_1_iff_3 : s ∈ 𝓝[>] a ↔ s ∈ 𝓝[Ioo a b] a tfae_4_to_5 : (∃ u ∈ Ioc a b, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioo a u ⊆ s tfae_5_to_1 : (∃ u ∈ Ioi a, Ioo a u ⊆ s) → s ∈ 𝓝[>] a tfae_1_to_4 : s ∈ 𝓝[>] a → ∃ u ∈ Ioc a b, Ioo a u ⊆ s ⊢ TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1
tfae_finish
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1
Mathlib.Topology.Order.Basic.1634_0.Npdof1X5b8sCkZ2
open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s]
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a : α ⊢ 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by
by_cases ha : IsTop a
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by
Mathlib.Topology.Order.Basic.1687_0.Npdof1X5b8sCkZ2
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b
Mathlib_Topology_Order_Basic
case pos α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a : α ha : IsTop a ⊢ 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a ·
simp [ha, ha.isMax.Ioi_eq]
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a ·
Mathlib.Topology.Order.Basic.1687_0.Npdof1X5b8sCkZ2
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b
Mathlib_Topology_Order_Basic
case neg α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a : α ha : ¬IsTop a ⊢ 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] ·
simp only [ha, false_or]
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] ·
Mathlib.Topology.Order.Basic.1687_0.Npdof1X5b8sCkZ2
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b
Mathlib_Topology_Order_Basic
case neg α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a : α ha : ¬IsTop a ⊢ 𝓝[>] a = ⊥ ↔ ∃ b, a ⋖ b
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] · simp only [ha, false_or]
rw [isTop_iff_isMax, not_isMax_iff] at ha
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] · simp only [ha, false_or]
Mathlib.Topology.Order.Basic.1687_0.Npdof1X5b8sCkZ2
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b
Mathlib_Topology_Order_Basic
case neg α : Type u β : Type v γ : Type w inst✝² : TopologicalSpace α inst✝¹ : LinearOrder α inst✝ : OrderTopology α a : α ha : ∃ b, a < b ⊢ 𝓝[>] a = ⊥ ↔ ∃ b, a ⋖ b
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] · simp only [ha, false_or] rw [isTop_iff_isMax, not_isMax_iff] at ha
simp only [(nhdsWithin_Ioi_basis' ha).eq_bot_iff, covby_iff_Ioo_eq]
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] · simp only [ha, false_or] rw [isTop_iff_isMax, not_isMax_iff] at ha
Mathlib.Topology.Order.Basic.1687_0.Npdof1X5b8sCkZ2
theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ⊢ Set.Countable {x | 𝓝[>] x = ⊥}
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] · simp only [ha, false_or] rw [isTop_iff_isMax, not_isMax_iff] at ha simp only [(nhdsWithin_Ioi_basis' ha).eq_bot_iff, covby_iff_Ioo_eq] /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset [NoMaxOrder α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := let ⟨_u', hu'⟩ := exists_gt a mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' hu' #align mem_nhds_within_Ioi_iff_exists_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_Ioo_subset /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_isolated_right [SecondCountableTopology α] : { x : α | 𝓝[>] x = ⊥ }.Countable := by
simp only [nhdsWithin_Ioi_eq_bot_iff, setOf_or]
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_isolated_right [SecondCountableTopology α] : { x : α | 𝓝[>] x = ⊥ }.Countable := by
Mathlib.Topology.Order.Basic.1702_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_isolated_right [SecondCountableTopology α] : { x : α | 𝓝[>] x = ⊥ }.Countable
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝³ : TopologicalSpace α inst✝² : LinearOrder α inst✝¹ : OrderTopology α inst✝ : SecondCountableTopology α ⊢ Set.Countable ({a | IsTop a} ∪ {a | ∃ b, a ⋖ b})
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] · simp only [ha, false_or] rw [isTop_iff_isMax, not_isMax_iff] at ha simp only [(nhdsWithin_Ioi_basis' ha).eq_bot_iff, covby_iff_Ioo_eq] /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset [NoMaxOrder α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := let ⟨_u', hu'⟩ := exists_gt a mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' hu' #align mem_nhds_within_Ioi_iff_exists_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_Ioo_subset /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_isolated_right [SecondCountableTopology α] : { x : α | 𝓝[>] x = ⊥ }.Countable := by simp only [nhdsWithin_Ioi_eq_bot_iff, setOf_or]
exact (subsingleton_isTop α).countable.union countable_setOf_covby_right
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_isolated_right [SecondCountableTopology α] : { x : α | 𝓝[>] x = ⊥ }.Countable := by simp only [nhdsWithin_Ioi_eq_bot_iff, setOf_or]
Mathlib.Topology.Order.Basic.1702_0.Npdof1X5b8sCkZ2
/-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_isolated_right [SecondCountableTopology α] : { x : α | 𝓝[>] x = ⊥ }.Countable
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : NoMaxOrder α inst✝ : DenselyOrdered α a : α s : Set α ⊢ s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] · simp only [ha, false_or] rw [isTop_iff_isMax, not_isMax_iff] at ha simp only [(nhdsWithin_Ioi_basis' ha).eq_bot_iff, covby_iff_Ioo_eq] /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset [NoMaxOrder α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := let ⟨_u', hu'⟩ := exists_gt a mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' hu' #align mem_nhds_within_Ioi_iff_exists_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_Ioo_subset /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_isolated_right [SecondCountableTopology α] : { x : α | 𝓝[>] x = ⊥ }.Countable := by simp only [nhdsWithin_Ioi_eq_bot_iff, setOf_or] exact (subsingleton_isTop α).countable.union countable_setOf_covby_right /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_isolated_left [SecondCountableTopology α] : { x : α | 𝓝[<] x = ⊥ }.Countable := countable_setOf_isolated_right (α := αᵒᵈ) /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s := by
rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset]
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s := by
Mathlib.Topology.Order.Basic.1715_0.Npdof1X5b8sCkZ2
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s
Mathlib_Topology_Order_Basic
α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : NoMaxOrder α inst✝ : DenselyOrdered α a : α s : Set α ⊢ (∃ u ∈ Ioi a, Ioo a u ⊆ s) ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] · simp only [ha, false_or] rw [isTop_iff_isMax, not_isMax_iff] at ha simp only [(nhdsWithin_Ioi_basis' ha).eq_bot_iff, covby_iff_Ioo_eq] /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset [NoMaxOrder α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := let ⟨_u', hu'⟩ := exists_gt a mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' hu' #align mem_nhds_within_Ioi_iff_exists_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_Ioo_subset /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_isolated_right [SecondCountableTopology α] : { x : α | 𝓝[>] x = ⊥ }.Countable := by simp only [nhdsWithin_Ioi_eq_bot_iff, setOf_or] exact (subsingleton_isTop α).countable.union countable_setOf_covby_right /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_isolated_left [SecondCountableTopology α] : { x : α | 𝓝[<] x = ⊥ }.Countable := countable_setOf_isolated_right (α := αᵒᵈ) /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s := by rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset]
constructor
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s := by rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset]
Mathlib.Topology.Order.Basic.1715_0.Npdof1X5b8sCkZ2
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s
Mathlib_Topology_Order_Basic
case mp α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : NoMaxOrder α inst✝ : DenselyOrdered α a : α s : Set α ⊢ (∃ u ∈ Ioi a, Ioo a u ⊆ s) → ∃ u ∈ Ioi a, Ioc a u ⊆ s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] · simp only [ha, false_or] rw [isTop_iff_isMax, not_isMax_iff] at ha simp only [(nhdsWithin_Ioi_basis' ha).eq_bot_iff, covby_iff_Ioo_eq] /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset [NoMaxOrder α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := let ⟨_u', hu'⟩ := exists_gt a mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' hu' #align mem_nhds_within_Ioi_iff_exists_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_Ioo_subset /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_isolated_right [SecondCountableTopology α] : { x : α | 𝓝[>] x = ⊥ }.Countable := by simp only [nhdsWithin_Ioi_eq_bot_iff, setOf_or] exact (subsingleton_isTop α).countable.union countable_setOf_covby_right /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_isolated_left [SecondCountableTopology α] : { x : α | 𝓝[<] x = ⊥ }.Countable := countable_setOf_isolated_right (α := αᵒᵈ) /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s := by rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset] constructor ·
rintro ⟨u, au, as⟩
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s := by rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset] constructor ·
Mathlib.Topology.Order.Basic.1715_0.Npdof1X5b8sCkZ2
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s
Mathlib_Topology_Order_Basic
case mp.intro.intro α : Type u β : Type v γ : Type w inst✝⁴ : TopologicalSpace α inst✝³ : LinearOrder α inst✝² : OrderTopology α inst✝¹ : NoMaxOrder α inst✝ : DenselyOrdered α a : α s : Set α u : α au : u ∈ Ioi a as : Ioo a u ⊆ s ⊢ ∃ u ∈ Ioi a, Ioc a u ⊆ s
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Data.Set.Intervals.Pi import Mathlib.Data.Set.Pointwise.Interval import Mathlib.Order.Filter.Interval import Mathlib.Tactic.TFAE import Mathlib.Topology.Support import Mathlib.Topology.Algebra.Order.LeftRight #align_import topology.order.basic from "leanprover-community/mathlib"@"3efd324a3a31eaa40c9d5bfc669c4fafee5f9423" /-! # Theory of topology on ordered spaces ## Main definitions The order topology on an ordered space is the topology generated by all open intervals (or equivalently by those of the form `(-∞, a)` and `(b, +∞)`). We define it as `Preorder.topology α`. However, we do *not* register it as an instance (as many existing ordered types already have topologies, which would be equal but not definitionally equal to `Preorder.topology α`). Instead, we introduce a class `OrderTopology α` (which is a `Prop`, also known as a mixin) saying that on the type `α` having already a topological space structure and a preorder structure, the topological structure is equal to the order topology. We also introduce another (mixin) class `OrderClosedTopology α` saying that the set of points `(x, y)` with `x ≤ y` is closed in the product space. This is automatically satisfied on a linear order with the order topology. We prove many basic properties of such topologies. ## Main statements This file contains the proofs of the following facts. For exact requirements (`OrderClosedTopology` vs `OrderTopology`, `Preorder` vs `PartialOrder` vs `LinearOrder` etc) see their statements. ### Open / closed sets * `isOpen_lt` : if `f` and `g` are continuous functions, then `{x | f x < g x}` is open; * `isOpen_Iio`, `isOpen_Ioi`, `isOpen_Ioo` : open intervals are open; * `isClosed_le` : if `f` and `g` are continuous functions, then `{x | f x ≤ g x}` is closed; * `isClosed_Iic`, `isClosed_Ici`, `isClosed_Icc` : closed intervals are closed; * `frontier_le_subset_eq`, `frontier_lt_subset_eq` : frontiers of both `{x | f x ≤ g x}` and `{x | f x < g x}` are included by `{x | f x = g x}`; * `exists_Ioc_subset_of_mem_nhds`, `exists_Ico_subset_of_mem_nhds` : if `x < y`, then any neighborhood of `x` includes an interval `[x, z)` for some `z ∈ (x, y]`, and any neighborhood of `y` includes an interval `(z, y]` for some `z ∈ [x, y)`. ### Convergence and inequalities * `le_of_tendsto_of_tendsto` : if `f` converges to `a`, `g` converges to `b`, and eventually `f x ≤ g x`, then `a ≤ b` * `le_of_tendsto`, `ge_of_tendsto` : if `f` converges to `a` and eventually `f x ≤ b` (resp., `b ≤ f x`), then `a ≤ b` (resp., `b ≤ a`); we also provide primed versions that assume the inequalities to hold for all `x`. ### Min, max, `sSup` and `sInf` * `Continuous.min`, `Continuous.max`: pointwise `min`/`max` of two continuous functions is continuous. * `Tendsto.min`, `Tendsto.max` : if `f` tends to `a` and `g` tends to `b`, then their pointwise `min`/`max` tend to `min a b` and `max a b`, respectively. * `tendsto_of_tendsto_of_tendsto_of_le_of_le` : theorem known as squeeze theorem, sandwich theorem, theorem of Carabinieri, and two policemen (and a drunk) theorem; if `g` and `h` both converge to `a`, and eventually `g x ≤ f x ≤ h x`, then `f` converges to `a`. ## Implementation notes We do _not_ register the order topology as an instance on a preorder (or even on a linear order). Indeed, on many such spaces, a topology has already been constructed in a different way (think of the discrete spaces `ℕ` or `ℤ`, or `ℝ` that could inherit a topology as the completion of `ℚ`), and is in general not defeq to the one generated by the intervals. We make it available as a definition `Preorder.topology α` though, that can be registered as an instance when necessary, or for specific types. -/ open Set Filter TopologicalSpace Topology Function open OrderDual (toDual ofDual) universe u v w variable {α : Type u} {β : Type v} {γ : Type w} /-- If `α` is a topological space and a preorder, `ClosedIicTopology α` means that `Iic a` is closed for all `a : α`. -/ class ClosedIicTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | b ≤ a}` is closed. -/ isClosed_le' (a : α) : IsClosed { b : α | b ≤ a } export ClosedIicTopology (isClosed_le') #align is_closed_le' ClosedIicTopology.isClosed_le' /-- If `α` is a topological space and a preorder, `ClosedIciTopology α` means that `Ici a` is closed for all `a : α`. -/ class ClosedIciTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- For any `a`, the set `{b | a ≤ b}` is closed. -/ isClosed_ge' (a : α) : IsClosed { b : α | a ≤ b } export ClosedIciTopology (isClosed_ge') #align is_closed_ge' ClosedIciTopology.isClosed_ge' /-- A topology on a set which is both a topological space and a preorder is _order-closed_ if the set of points `(x, y)` with `x ≤ y` is closed in the product space. We introduce this as a mixin. This property is satisfied for the order topology on a linear order, but it can be satisfied more generally, and suffices to derive many interesting properties relating order and topology. -/ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Prop where /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } #align order_closed_topology OrderClosedTopology instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := hs #align dense.order_dual Dense.orderDual section ClosedIicTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIicTopology α] instance : ClosedIciTopology αᵒᵈ where isClosed_ge' a := isClosed_le' (α := α) a theorem isClosed_Iic {a : α} : IsClosed (Iic a) := isClosed_le' a #align is_closed_Iic isClosed_Iic @[simp] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := isClosed_Iic.closure_eq #align closure_Iic closure_Iic theorem le_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, f c ≤ b) : a ≤ b := (isClosed_le' b).mem_of_tendsto lim h #align le_of_tendsto le_of_tendsto theorem le_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, f c ≤ b) : a ≤ b := le_of_tendsto lim (eventually_of_forall h) #align le_of_tendsto' le_of_tendsto' end ClosedIicTopology section ClosedIciTopology variable [TopologicalSpace α] [Preorder α] [t : ClosedIciTopology α] instance : ClosedIicTopology αᵒᵈ where isClosed_le' a := isClosed_ge' (α := α) a theorem isClosed_Ici {a : α} : IsClosed (Ici a) := isClosed_ge' a #align is_closed_Ici isClosed_Ici @[simp] theorem closure_Ici (a : α) : closure (Ici a) = Ici a := isClosed_Ici.closure_eq #align closure_Ici closure_Ici theorem ge_of_tendsto {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ᶠ c in x, b ≤ f c) : b ≤ a := (isClosed_ge' b).mem_of_tendsto lim h #align ge_of_tendsto ge_of_tendsto theorem ge_of_tendsto' {f : β → α} {a b : α} {x : Filter β} [NeBot x] (lim : Tendsto f x (𝓝 a)) (h : ∀ c, b ≤ f c) : b ≤ a := ge_of_tendsto lim (eventually_of_forall h) #align ge_of_tendsto' ge_of_tendsto' end ClosedIciTopology section OrderClosedTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderClosedTopology α] namespace Subtype -- todo: add `OrderEmbedding.orderClosedTopology` instance {p : α → Prop} : OrderClosedTopology (Subtype p) := have this : Continuous fun p : Subtype p × Subtype p => ((p.fst : α), (p.snd : α)) := continuous_subtype_val.prod_map continuous_subtype_val OrderClosedTopology.mk (t.isClosed_le'.preimage this) end Subtype theorem isClosed_le_prod : IsClosed { p : α × α | p.1 ≤ p.2 } := t.isClosed_le' #align is_closed_le_prod isClosed_le_prod theorem isClosed_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsClosed { b | f b ≤ g b } := continuous_iff_isClosed.mp (hf.prod_mk hg) _ isClosed_le_prod #align is_closed_le isClosed_le instance : ClosedIicTopology α where isClosed_le' _ := isClosed_le continuous_id continuous_const instance : ClosedIciTopology α where isClosed_ge' _ := isClosed_le continuous_const continuous_id instance : OrderClosedTopology αᵒᵈ := ⟨(OrderClosedTopology.isClosed_le' (α := α)).preimage continuous_swap⟩ theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := IsClosed.inter isClosed_Ici isClosed_Iic #align is_closed_Icc isClosed_Icc @[simp] theorem closure_Icc (a b : α) : closure (Icc a b) = Icc a b := isClosed_Icc.closure_eq #align closure_Icc closure_Icc theorem le_of_tendsto_of_tendsto {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : f ≤ᶠ[b] g) : a₁ ≤ a₂ := have : Tendsto (fun b => (f b, g b)) b (𝓝 (a₁, a₂)) := hf.prod_mk_nhds hg show (a₁, a₂) ∈ { p : α × α | p.1 ≤ p.2 } from t.isClosed_le'.mem_of_tendsto this h #align le_of_tendsto_of_tendsto le_of_tendsto_of_tendsto alias tendsto_le_of_eventuallyLE := le_of_tendsto_of_tendsto #align tendsto_le_of_eventually_le tendsto_le_of_eventuallyLE theorem le_of_tendsto_of_tendsto' {f g : β → α} {b : Filter β} {a₁ a₂ : α} [NeBot b] (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) (h : ∀ x, f x ≤ g x) : a₁ ≤ a₂ := le_of_tendsto_of_tendsto hf hg (eventually_of_forall h) #align le_of_tendsto_of_tendsto' le_of_tendsto_of_tendsto' @[simp] theorem closure_le_eq [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b ≤ g b } = { b | f b ≤ g b } := (isClosed_le hf hg).closure_eq #align closure_le_eq closure_le_eq theorem closure_lt_subset_le [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : closure { b | f b < g b } ⊆ { b | f b ≤ g b } := (closure_minimal fun _ => le_of_lt) <| isClosed_le hf hg #align closure_lt_subset_le closure_lt_subset_le theorem ContinuousWithinAt.closure_le [TopologicalSpace β] {f g : β → α} {s : Set β} {x : β} (hx : x ∈ closure s) (hf : ContinuousWithinAt f s x) (hg : ContinuousWithinAt g s x) (h : ∀ y ∈ s, f y ≤ g y) : f x ≤ g x := show (f x, g x) ∈ { p : α × α | p.1 ≤ p.2 } from OrderClosedTopology.isClosed_le'.closure_subset ((hf.prod hg).mem_closure hx h) #align continuous_within_at.closure_le ContinuousWithinAt.closure_le /-- If `s` is a closed set and two functions `f` and `g` are continuous on `s`, then the set `{x ∈ s | f x ≤ g x}` is a closed set. -/ theorem IsClosed.isClosed_le [TopologicalSpace β] {f g : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) (hg : ContinuousOn g s) : IsClosed ({ x ∈ s | f x ≤ g x }) := (hf.prod hg).preimage_isClosed_of_isClosed hs OrderClosedTopology.isClosed_le' #align is_closed.is_closed_le IsClosed.isClosed_le theorem le_on_closure [TopologicalSpace β] {f g : β → α} {s : Set β} (h : ∀ x ∈ s, f x ≤ g x) (hf : ContinuousOn f (closure s)) (hg : ContinuousOn g (closure s)) ⦃x⦄ (hx : x ∈ closure s) : f x ≤ g x := have : s ⊆ { y ∈ closure s | f y ≤ g y } := fun y hy => ⟨subset_closure hy, h y hy⟩ (closure_minimal this (isClosed_closure.isClosed_le hf hg) hx).2 #align le_on_closure le_on_closure theorem IsClosed.epigraph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ f p.1 ≤ p.2 } := (hs.preimage continuous_fst).isClosed_le (hf.comp continuousOn_fst Subset.rfl) continuousOn_snd #align is_closed.epigraph IsClosed.epigraph theorem IsClosed.hypograph [TopologicalSpace β] {f : β → α} {s : Set β} (hs : IsClosed s) (hf : ContinuousOn f s) : IsClosed { p : β × α | p.1 ∈ s ∧ p.2 ≤ f p.1 } := (hs.preimage continuous_fst).isClosed_le continuousOn_snd (hf.comp continuousOn_fst Subset.rfl) #align is_closed.hypograph IsClosed.hypograph end Preorder section PartialOrder variable [TopologicalSpace α] [PartialOrder α] [t : OrderClosedTopology α] -- see Note [lower instance priority] instance (priority := 90) OrderClosedTopology.to_t2Space : T2Space α := t2_iff_isClosed_diagonal.2 <| by simpa only [diagonal, le_antisymm_iff] using t.isClosed_le'.inter (isClosed_le continuous_snd continuous_fst) #align order_closed_topology.to_t2_space OrderClosedTopology.to_t2Space end PartialOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] theorem isOpen_lt [TopologicalSpace β] {f g : β → α} (hf : Continuous f) (hg : Continuous g) : IsOpen { b | f b < g b } := by simpa only [lt_iff_not_le] using (isClosed_le hg hf).isOpen_compl #align is_open_lt isOpen_lt theorem isOpen_lt_prod : IsOpen { p : α × α | p.1 < p.2 } := isOpen_lt continuous_fst continuous_snd #align is_open_lt_prod isOpen_lt_prod variable {a b : α} theorem isOpen_Iio : IsOpen (Iio a) := isOpen_lt continuous_id continuous_const #align is_open_Iio isOpen_Iio theorem isOpen_Ioi : IsOpen (Ioi a) := isOpen_lt continuous_const continuous_id #align is_open_Ioi isOpen_Ioi theorem isOpen_Ioo : IsOpen (Ioo a b) := IsOpen.inter isOpen_Ioi isOpen_Iio #align is_open_Ioo isOpen_Ioo @[simp] theorem interior_Ioi : interior (Ioi a) = Ioi a := isOpen_Ioi.interior_eq #align interior_Ioi interior_Ioi @[simp] theorem interior_Iio : interior (Iio a) = Iio a := isOpen_Iio.interior_eq #align interior_Iio interior_Iio @[simp] theorem interior_Ioo : interior (Ioo a b) = Ioo a b := isOpen_Ioo.interior_eq #align interior_Ioo interior_Ioo theorem Ioo_subset_closure_interior : Ioo a b ⊆ closure (interior (Ioo a b)) := by simp only [interior_Ioo, subset_closure] #align Ioo_subset_closure_interior Ioo_subset_closure_interior theorem Iio_mem_nhds {a b : α} (h : a < b) : Iio b ∈ 𝓝 a := IsOpen.mem_nhds isOpen_Iio h #align Iio_mem_nhds Iio_mem_nhds theorem Ioi_mem_nhds {a b : α} (h : a < b) : Ioi a ∈ 𝓝 b := IsOpen.mem_nhds isOpen_Ioi h #align Ioi_mem_nhds Ioi_mem_nhds theorem Iic_mem_nhds {a b : α} (h : a < b) : Iic b ∈ 𝓝 a := mem_of_superset (Iio_mem_nhds h) Iio_subset_Iic_self #align Iic_mem_nhds Iic_mem_nhds theorem Ici_mem_nhds {a b : α} (h : a < b) : Ici a ∈ 𝓝 b := mem_of_superset (Ioi_mem_nhds h) Ioi_subset_Ici_self #align Ici_mem_nhds Ici_mem_nhds theorem Ioo_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioo a b ∈ 𝓝 x := IsOpen.mem_nhds isOpen_Ioo ⟨ha, hb⟩ #align Ioo_mem_nhds Ioo_mem_nhds theorem Ioc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ioc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ioc_self #align Ioc_mem_nhds Ioc_mem_nhds theorem Ico_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Ico a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Ico_self #align Ico_mem_nhds Ico_mem_nhds theorem Icc_mem_nhds {a b x : α} (ha : a < x) (hb : x < b) : Icc a b ∈ 𝓝 x := mem_of_superset (Ioo_mem_nhds ha hb) Ioo_subset_Icc_self #align Icc_mem_nhds Icc_mem_nhds theorem eventually_lt_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a < u := tendsto_nhds.1 h (· < u) isOpen_Iio hv #align eventually_lt_of_tendsto_lt eventually_lt_of_tendsto_lt theorem eventually_gt_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Filter.Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u < f a := tendsto_nhds.1 h (· > u) isOpen_Ioi hv #align eventually_gt_of_tendsto_gt eventually_gt_of_tendsto_gt theorem eventually_le_of_tendsto_lt {l : Filter γ} {f : γ → α} {u v : α} (hv : v < u) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, f a ≤ u := (eventually_lt_of_tendsto_lt hv h).mono fun _ => le_of_lt #align eventually_le_of_tendsto_lt eventually_le_of_tendsto_lt theorem eventually_ge_of_tendsto_gt {l : Filter γ} {f : γ → α} {u v : α} (hv : u < v) (h : Tendsto f l (𝓝 v)) : ∀ᶠ a in l, u ≤ f a := (eventually_gt_of_tendsto_gt hv h).mono fun _ => le_of_lt #align eventually_ge_of_tendsto_gt eventually_ge_of_tendsto_gt variable [TopologicalSpace γ] /-! ### Neighborhoods to the left and to the right on an `OrderClosedTopology` Limits to the left and to the right of real functions are defined in terms of neighborhoods to the left and to the right, either open or closed, i.e., members of `𝓝[>] a` and `𝓝[≥] a` on the right, and similarly on the left. Here we simply prove that all right-neighborhoods of a point are equal, and we'll prove later other useful characterizations which require the stronger hypothesis `OrderTopology α` -/ /-! #### Right neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioo a c ∈ 𝓝[>] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by rw [inter_comm, Ioi_inter_Iio]; exact Ioo_subset_Ioo_left H.1⟩ #align Ioo_mem_nhds_within_Ioi Ioo_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[>] a := Ioo_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Covby.nhdsWithin_Ioi {a b : α} (h : a ⋖ b) : 𝓝[>] a = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Ioi' h.1 theorem Ioc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ioc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ioi Ioc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Ico_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Ioi Ico_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[>] a := Ico_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ioi {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[>] b := mem_of_superset (Ioo_mem_nhdsWithin_Ioi H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Ioi Icc_mem_nhdsWithin_Ioi -- porting note: new lemma; todo: swap `'`? theorem Icc_mem_nhdsWithin_Ioi' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[>] a := Icc_mem_nhdsWithin_Ioi ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioc a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Ioc_eq_nhds_within_Ioi nhdsWithin_Ioc_eq_nhdsWithin_Ioi @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Ioi {a b : α} (h : a < b) : 𝓝[Ioo a b] a = 𝓝[>] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ioo_eq_nhds_within_Ioi nhdsWithin_Ioo_eq_nhdsWithin_Ioi @[simp] theorem continuousWithinAt_Ioc_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioc_iff_Ioi continuousWithinAt_Ioc_iff_Ioi @[simp] theorem continuousWithinAt_Ioo_iff_Ioi [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioo a b) a ↔ ContinuousWithinAt f (Ioi a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Ioi h] #align continuous_within_at_Ioo_iff_Ioi continuousWithinAt_Ioo_iff_Ioi /-! #### Left neighborhoods, point excluded -/ theorem Ioo_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioo a c ∈ 𝓝[<] b := by simpa only [dual_Ioo] using Ioo_mem_nhdsWithin_Ioi (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioo_mem_nhds_within_Iio Ioo_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioo_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioo a b ∈ 𝓝[<] b := Ioo_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Covby.nhdsWithin_Iio {a b : α} (h : a ⋖ b) : 𝓝[<] b = ⊥ := empty_mem_iff_bot.mp <| h.Ioo_eq ▸ Ioo_mem_nhdsWithin_Iio' h.1 theorem Ico_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ico a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iio Ico_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ico_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[<] b := Ico_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Ioc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Iio Ioc_mem_nhdsWithin_Iio -- porting note: new lemma; todo: swap `'`? theorem Ioc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[<] b := Ioc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iio {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[<] b := mem_of_superset (Ioo_mem_nhdsWithin_Iio H) Ioo_subset_Icc_self #align Icc_mem_nhds_within_Iio Icc_mem_nhdsWithin_Iio theorem Icc_mem_nhdsWithin_Iio' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[<] b := Icc_mem_nhdsWithin_Iio ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ico a b] b = 𝓝[<] b := by simpa only [dual_Ioc] using nhdsWithin_Ioc_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ico_eq_nhds_within_Iio nhdsWithin_Ico_eq_nhdsWithin_Iio @[simp] theorem nhdsWithin_Ioo_eq_nhdsWithin_Iio {a b : α} (h : a < b) : 𝓝[Ioo a b] b = 𝓝[<] b := by simpa only [dual_Ioo] using nhdsWithin_Ioo_eq_nhdsWithin_Ioi h.dual #align nhds_within_Ioo_eq_nhds_within_Iio nhdsWithin_Ioo_eq_nhdsWithin_Iio @[simp] theorem continuousWithinAt_Ico_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ico a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Iio h] #align continuous_within_at_Ico_iff_Iio continuousWithinAt_Ico_iff_Iio @[simp] theorem continuousWithinAt_Ioo_iff_Iio {a b : α} {f : α → γ} (h : a < b) : ContinuousWithinAt f (Ioo a b) b ↔ ContinuousWithinAt f (Iio b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioo_eq_nhdsWithin_Iio h] #align continuous_within_at_Ioo_iff_Iio continuousWithinAt_Ioo_iff_Iio /-! #### Right neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≥] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Ici Ioo_mem_nhdsWithin_Ici theorem Ioc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ioo a c) : Ioc a c ∈ 𝓝[≥] b := mem_of_superset (Ioo_mem_nhdsWithin_Ici H) Ioo_subset_Ioc_self #align Ioc_mem_nhds_within_Ici Ioc_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Ico a c ∈ 𝓝[≥] b := mem_nhdsWithin.2 ⟨Iio c, isOpen_Iio, H.2, by simp only [inter_comm, Ici_inter_Iio, Ico_subset_Ico_left H.1]⟩ #align Ico_mem_nhds_within_Ici Ico_mem_nhdsWithin_Ici theorem Ico_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Ico a b ∈ 𝓝[≥] a := Ico_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ theorem Icc_mem_nhdsWithin_Ici {a b c : α} (H : b ∈ Ico a c) : Icc a c ∈ 𝓝[≥] b := mem_of_superset (Ico_mem_nhdsWithin_Ici H) Ico_subset_Icc_self #align Icc_mem_nhds_within_Ici Icc_mem_nhdsWithin_Ici theorem Icc_mem_nhdsWithin_Ici' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≥] a := Icc_mem_nhdsWithin_Ici ⟨le_rfl, H⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Icc a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iic_mem_nhds h #align nhds_within_Icc_eq_nhds_within_Ici nhdsWithin_Icc_eq_nhdsWithin_Ici @[simp] theorem nhdsWithin_Ico_eq_nhdsWithin_Ici {a b : α} (h : a < b) : 𝓝[Ico a b] a = 𝓝[≥] a := nhdsWithin_inter_of_mem' <| nhdsWithin_le_nhds <| Iio_mem_nhds h #align nhds_within_Ico_eq_nhds_within_Ici nhdsWithin_Ico_eq_nhdsWithin_Ici @[simp] theorem continuousWithinAt_Icc_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Ici h] #align continuous_within_at_Icc_iff_Ici continuousWithinAt_Icc_iff_Ici @[simp] theorem continuousWithinAt_Ico_iff_Ici [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ico a b) a ↔ ContinuousWithinAt f (Ici a) a := by simp only [ContinuousWithinAt, nhdsWithin_Ico_eq_nhdsWithin_Ici h] #align continuous_within_at_Ico_iff_Ici continuousWithinAt_Ico_iff_Ici /-! #### Left neighborhoods, point included -/ theorem Ioo_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ioo a c ∈ 𝓝[≤] b := mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds isOpen_Ioo H #align Ioo_mem_nhds_within_Iic Ioo_mem_nhdsWithin_Iic theorem Ico_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioo a c) : Ico a c ∈ 𝓝[≤] b := mem_of_superset (Ioo_mem_nhdsWithin_Iic H) Ioo_subset_Ico_self #align Ico_mem_nhds_within_Iic Ico_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Ioc a c ∈ 𝓝[≤] b := by simpa only [dual_Ico] using Ico_mem_nhdsWithin_Ici (show toDual b ∈ Ico (toDual c) (toDual a) from H.symm) #align Ioc_mem_nhds_within_Iic Ioc_mem_nhdsWithin_Iic theorem Ioc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Ioc a b ∈ 𝓝[≤] b := Ioc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ theorem Icc_mem_nhdsWithin_Iic {a b c : α} (H : b ∈ Ioc a c) : Icc a c ∈ 𝓝[≤] b := mem_of_superset (Ioc_mem_nhdsWithin_Iic H) Ioc_subset_Icc_self #align Icc_mem_nhds_within_Iic Icc_mem_nhdsWithin_Iic theorem Icc_mem_nhdsWithin_Iic' {a b : α} (H : a < b) : Icc a b ∈ 𝓝[≤] b := Icc_mem_nhdsWithin_Iic ⟨H, le_rfl⟩ @[simp] theorem nhdsWithin_Icc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Icc a b] b = 𝓝[≤] b := by simpa only [dual_Icc] using nhdsWithin_Icc_eq_nhdsWithin_Ici h.dual #align nhds_within_Icc_eq_nhds_within_Iic nhdsWithin_Icc_eq_nhdsWithin_Iic @[simp] theorem nhdsWithin_Ioc_eq_nhdsWithin_Iic {a b : α} (h : a < b) : 𝓝[Ioc a b] b = 𝓝[≤] b := by simpa only [dual_Ico] using nhdsWithin_Ico_eq_nhdsWithin_Ici h.dual #align nhds_within_Ioc_eq_nhds_within_Iic nhdsWithin_Ioc_eq_nhdsWithin_Iic @[simp] theorem continuousWithinAt_Icc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Icc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Icc_eq_nhdsWithin_Iic h] #align continuous_within_at_Icc_iff_Iic continuousWithinAt_Icc_iff_Iic @[simp] theorem continuousWithinAt_Ioc_iff_Iic [TopologicalSpace β] {a b : α} {f : α → β} (h : a < b) : ContinuousWithinAt f (Ioc a b) b ↔ ContinuousWithinAt f (Iic b) b := by simp only [ContinuousWithinAt, nhdsWithin_Ioc_eq_nhdsWithin_Iic h] #align continuous_within_at_Ioc_iff_Iic continuousWithinAt_Ioc_iff_Iic end LinearOrder section LinearOrder variable [TopologicalSpace α] [LinearOrder α] [OrderClosedTopology α] {f g : β → α} section variable [TopologicalSpace β] theorem lt_subset_interior_le (hf : Continuous f) (hg : Continuous g) : { b | f b < g b } ⊆ interior { b | f b ≤ g b } := (interior_maximal fun _ => le_of_lt) <| isOpen_lt hf hg #align lt_subset_interior_le lt_subset_interior_le theorem frontier_le_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b ≤ g b } ⊆ { b | f b = g b } := by rw [frontier_eq_closure_inter_closure, closure_le_eq hf hg] rintro b ⟨hb₁, hb₂⟩ refine' le_antisymm hb₁ (closure_lt_subset_le hg hf _) convert hb₂ using 2; simp only [not_le.symm]; rfl #align frontier_le_subset_eq frontier_le_subset_eq theorem frontier_Iic_subset (a : α) : frontier (Iic a) ⊆ {a} := frontier_le_subset_eq (@continuous_id α _) continuous_const #align frontier_Iic_subset frontier_Iic_subset theorem frontier_Ici_subset (a : α) : frontier (Ici a) ⊆ {a} := frontier_Iic_subset (α := αᵒᵈ) _ #align frontier_Ici_subset frontier_Ici_subset theorem frontier_lt_subset_eq (hf : Continuous f) (hg : Continuous g) : frontier { b | f b < g b } ⊆ { b | f b = g b } := by simpa only [← not_lt, ← compl_setOf, frontier_compl, eq_comm] using frontier_le_subset_eq hg hf #align frontier_lt_subset_eq frontier_lt_subset_eq theorem continuous_if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf : Continuous f) (hg : Continuous g) (hf' : ContinuousOn f' { x | f x ≤ g x }) (hg' : ContinuousOn g' { x | g x ≤ f x }) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := by refine' continuous_if (fun a ha => hfg _ (frontier_le_subset_eq hf hg ha)) _ (hg'.mono _) · rwa [(isClosed_le hf hg).closure_eq] · simp only [not_le] exact closure_lt_subset_le hg hf #align continuous_if_le continuous_if_le theorem Continuous.if_le [TopologicalSpace γ] [∀ x, Decidable (f x ≤ g x)] {f' g' : β → γ} (hf' : Continuous f') (hg' : Continuous g') (hf : Continuous f) (hg : Continuous g) (hfg : ∀ x, f x = g x → f' x = g' x) : Continuous fun x => if f x ≤ g x then f' x else g' x := continuous_if_le hf hg hf'.continuousOn hg'.continuousOn hfg #align continuous.if_le Continuous.if_le theorem Filter.Tendsto.eventually_lt {l : Filter γ} {f g : γ → α} {y z : α} (hf : Tendsto f l (𝓝 y)) (hg : Tendsto g l (𝓝 z)) (hyz : y < z) : ∀ᶠ x in l, f x < g x := let ⟨_a, ha, _b, hb, h⟩ := hyz.exists_disjoint_Iio_Ioi (hg.eventually (Ioi_mem_nhds hb)).mp <| (hf.eventually (Iio_mem_nhds ha)).mono fun _ h₁ h₂ => h _ h₁ _ h₂ #align tendsto.eventually_lt Filter.Tendsto.eventually_lt nonrec theorem ContinuousAt.eventually_lt {x₀ : β} (hf : ContinuousAt f x₀) (hg : ContinuousAt g x₀) (hfg : f x₀ < g x₀) : ∀ᶠ x in 𝓝 x₀, f x < g x := hf.eventually_lt hg hfg #align continuous_at.eventually_lt ContinuousAt.eventually_lt @[continuity] protected theorem Continuous.min (hf : Continuous f) (hg : Continuous g) : Continuous fun b => min (f b) (g b) := by simp only [min_def] exact hf.if_le hg hf hg fun x => id #align continuous.min Continuous.min @[continuity] protected theorem Continuous.max (hf : Continuous f) (hg : Continuous g) : Continuous fun b => max (f b) (g b) := Continuous.min (α := αᵒᵈ) hf hg #align continuous.max Continuous.max end theorem continuous_min : Continuous fun p : α × α => min p.1 p.2 := continuous_fst.min continuous_snd #align continuous_min continuous_min theorem continuous_max : Continuous fun p : α × α => max p.1 p.2 := continuous_fst.max continuous_snd #align continuous_max continuous_max protected theorem Filter.Tendsto.max {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => max (f b) (g b)) b (𝓝 (max a₁ a₂)) := (continuous_max.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.max Filter.Tendsto.max protected theorem Filter.Tendsto.min {b : Filter β} {a₁ a₂ : α} (hf : Tendsto f b (𝓝 a₁)) (hg : Tendsto g b (𝓝 a₂)) : Tendsto (fun b => min (f b) (g b)) b (𝓝 (min a₁ a₂)) := (continuous_min.tendsto (a₁, a₂)).comp (hf.prod_mk_nhds hg) #align filter.tendsto.min Filter.Tendsto.min protected theorem Filter.Tendsto.max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max a (f i)) l (𝓝 a) := by convert ((continuous_max.comp (@Continuous.Prod.mk α α _ _ a)).tendsto a).comp h simp #align filter.tendsto.max_right Filter.Tendsto.max_right protected theorem Filter.Tendsto.max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => max (f i) a) l (𝓝 a) := by simp_rw [max_comm _ a] exact h.max_right #align filter.tendsto.max_left Filter.Tendsto.max_left theorem Filter.tendsto_nhds_max_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max a (f i)) l (𝓝[>] a) := by obtain ⟨h₁ : Tendsto f l (𝓝 a), h₂ : ∀ᶠ i in l, f i ∈ Ioi a⟩ := tendsto_nhdsWithin_iff.mp h exact tendsto_nhdsWithin_iff.mpr ⟨h₁.max_right, h₂.mono fun i hi => lt_max_of_lt_right hi⟩ #align filter.tendsto_nhds_max_right Filter.tendsto_nhds_max_right theorem Filter.tendsto_nhds_max_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[>] a)) : Tendsto (fun i => max (f i) a) l (𝓝[>] a) := by simp_rw [max_comm _ a] exact Filter.tendsto_nhds_max_right h #align filter.tendsto_nhds_max_left Filter.tendsto_nhds_max_left theorem Filter.Tendsto.min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min a (f i)) l (𝓝 a) := Filter.Tendsto.max_right (α := αᵒᵈ) h #align filter.tendsto.min_right Filter.Tendsto.min_right theorem Filter.Tendsto.min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝 a)) : Tendsto (fun i => min (f i) a) l (𝓝 a) := Filter.Tendsto.max_left (α := αᵒᵈ) h #align filter.tendsto.min_left Filter.Tendsto.min_left theorem Filter.tendsto_nhds_min_right {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min a (f i)) l (𝓝[<] a) := Filter.tendsto_nhds_max_right (α := αᵒᵈ) h #align filter.tendsto_nhds_min_right Filter.tendsto_nhds_min_right theorem Filter.tendsto_nhds_min_left {l : Filter β} {a : α} (h : Tendsto f l (𝓝[<] a)) : Tendsto (fun i => min (f i) a) l (𝓝[<] a) := Filter.tendsto_nhds_max_left (α := αᵒᵈ) h #align filter.tendsto_nhds_min_left Filter.tendsto_nhds_min_left protected theorem Dense.exists_lt [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y < x := hs.exists_mem_open isOpen_Iio (exists_lt x) #align dense.exists_lt Dense.exists_lt protected theorem Dense.exists_gt [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x < y := hs.orderDual.exists_lt x #align dense.exists_gt Dense.exists_gt protected theorem Dense.exists_le [NoMinOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, y ≤ x := (hs.exists_lt x).imp fun _ h => ⟨h.1, h.2.le⟩ #align dense.exists_le Dense.exists_le protected theorem Dense.exists_ge [NoMaxOrder α] {s : Set α} (hs : Dense s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le x #align dense.exists_ge Dense.exists_ge theorem Dense.exists_le' {s : Set α} (hs : Dense s) (hbot : ∀ x, IsBot x → x ∈ s) (x : α) : ∃ y ∈ s, y ≤ x := by by_cases hx : IsBot x · exact ⟨x, hbot x hx, le_rfl⟩ · simp only [IsBot, not_forall, not_le] at hx rcases hs.exists_mem_open isOpen_Iio hx with ⟨y, hys, hy : y < x⟩ exact ⟨y, hys, hy.le⟩ #align dense.exists_le' Dense.exists_le' theorem Dense.exists_ge' {s : Set α} (hs : Dense s) (htop : ∀ x, IsTop x → x ∈ s) (x : α) : ∃ y ∈ s, x ≤ y := hs.orderDual.exists_le' htop x #align dense.exists_ge' Dense.exists_ge' theorem Dense.exists_between [DenselyOrdered α] {s : Set α} (hs : Dense s) {x y : α} (h : x < y) : ∃ z ∈ s, z ∈ Ioo x y := hs.exists_mem_open isOpen_Ioo (nonempty_Ioo.2 h) #align dense.exists_between Dense.exists_between theorem Dense.Ioi_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Ioi x = ⋃ y ∈ s ∩ Ioi x, Ioi y := by refine Subset.antisymm (fun z hz ↦ ?_) (iUnion₂_subset fun y hy ↦ Ioi_subset_Ioi (le_of_lt hy.2)) rcases hs.exists_between hz with ⟨y, hys, hxy, hyz⟩ exact mem_iUnion₂.2 ⟨y, ⟨hys, hxy⟩, hyz⟩ theorem Dense.Iio_eq_biUnion [DenselyOrdered α] {s : Set α} (hs : Dense s) (x : α) : Iio x = ⋃ y ∈ s ∩ Iio x, Iio y := Dense.Ioi_eq_biUnion (α := αᵒᵈ) hs x end LinearOrder end OrderClosedTopology instance [Preorder α] [TopologicalSpace α] [OrderClosedTopology α] [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α × β) := ⟨(isClosed_le continuous_fst.fst continuous_snd.fst).inter (isClosed_le continuous_fst.snd continuous_snd.snd)⟩ instance {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderClosedTopology (α i)] : OrderClosedTopology (∀ i, α i) := by constructor simp only [Pi.le_def, setOf_forall] exact isClosed_iInter fun i => isClosed_le (continuous_apply i).fst' (continuous_apply i).snd' instance Pi.orderClosedTopology' [Preorder β] [TopologicalSpace β] [OrderClosedTopology β] : OrderClosedTopology (α → β) := inferInstance #align pi.order_closed_topology' Pi.orderClosedTopology' -- porting note: todo: define `Preorder.topology` before `OrderTopology` and reuse the def /-- The order topology on an ordered type is the topology generated by open intervals. We register it on a preorder, but it is mostly interesting in linear orders, where it is also order-closed. We define it as a mixin. If you want to introduce the order topology on a preorder, use `Preorder.topology`. -/ class OrderTopology (α : Type*) [t : TopologicalSpace α] [Preorder α] : Prop where /-- The topology is generated by open intervals `Set.Ioi _` and `Set.Iio _`. -/ topology_eq_generate_intervals : t = generateFrom { s | ∃ a, s = Ioi a ∨ s = Iio a } #align order_topology OrderTopology /-- (Order) topology on a partial order `α` generated by the subbase of open intervals `(a, ∞) = { x ∣ a < x }, (-∞ , b) = {x ∣ x < b}` for all `a, b` in `α`. We do not register it as an instance as many ordered sets are already endowed with the same topology, most often in a non-defeq way though. Register as a local instance when necessary. -/ def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α := generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } } #align preorder.topology Preorder.topology section OrderTopology section Preorder variable [TopologicalSpace α] [Preorder α] [t : OrderTopology α] instance : OrderTopology αᵒᵈ := ⟨by convert OrderTopology.topology_eq_generate_intervals (α := α) using 6 apply or_comm⟩ theorem isOpen_iff_generate_intervals {s : Set α} : IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by rw [t.topology_eq_generate_intervals]; rfl #align is_open_iff_generate_intervals isOpen_iff_generate_intervals theorem isOpen_lt' (a : α) : IsOpen { b : α | a < b } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩ #align is_open_lt' isOpen_lt' theorem isOpen_gt' (a : α) : IsOpen { b : α | b < a } := isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩ #align is_open_gt' isOpen_gt' theorem lt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x := (isOpen_lt' _).mem_nhds h #align lt_mem_nhds lt_mem_nhds theorem le_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x := (lt_mem_nhds h).mono fun _ => le_of_lt #align le_mem_nhds le_mem_nhds theorem gt_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b := (isOpen_gt' _).mem_nhds h #align gt_mem_nhds gt_mem_nhds theorem ge_mem_nhds {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := (gt_mem_nhds h).mono fun _ => le_of_lt #align ge_mem_nhds ge_mem_nhds theorem nhds_eq_order (a : α) : 𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by rw [t.topology_eq_generate_intervals, nhds_generateFrom] simp_rw [mem_setOf_eq, @and_comm (a ∈ _), exists_or, or_and_right, iInf_or, iInf_and, iInf_exists, iInf_inf_eq, iInf_comm (ι := Set α), iInf_iInf_eq_left, mem_Ioi, mem_Iio] #align nhds_eq_order nhds_eq_order theorem tendsto_order {f : β → α} {a : α} {x : Filter β} : Tendsto f x (𝓝 a) ↔ (∀ a' < a, ∀ᶠ b in x, a' < f b) ∧ ∀ a' > a, ∀ᶠ b in x, f b < a' := by simp only [nhds_eq_order a, tendsto_inf, tendsto_iInf, tendsto_principal]; rfl #align tendsto_order tendsto_order instance tendstoIccClassNhds (a : α) : TendstoIxxClass Icc (𝓝 a) (𝓝 a) := by simp only [nhds_eq_order, iInf_subtype'] refine ((hasBasis_iInf_principal_finite _).inf (hasBasis_iInf_principal_finite _)).tendstoIxxClass fun s _ => ?_ refine' ((ordConnected_biInter _).inter (ordConnected_biInter _)).out <;> intro _ _ exacts [ordConnected_Ioi, ordConnected_Iio] #align tendsto_Icc_class_nhds tendstoIccClassNhds instance tendstoIcoClassNhds (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self #align tendsto_Ico_class_nhds tendstoIcoClassNhds instance tendstoIocClassNhds (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self #align tendsto_Ioc_class_nhds tendstoIocClassNhds instance tendstoIooClassNhds (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) := tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self #align tendsto_Ioo_class_nhds tendstoIooClassNhds /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold eventually for the filter. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : ∀ᶠ b in b, g b ≤ f b) (hfh : ∀ᶠ b in b, f b ≤ h b) : Tendsto f b (𝓝 a) := (hg.Icc hh).of_smallSets <| hgf.and hfh #align tendsto_of_tendsto_of_tendsto_of_le_of_le' tendsto_of_tendsto_of_tendsto_of_le_of_le' /-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities hold everywhere. -/ theorem tendsto_of_tendsto_of_tendsto_of_le_of_le {f g h : β → α} {b : Filter β} {a : α} (hg : Tendsto g b (𝓝 a)) (hh : Tendsto h b (𝓝 a)) (hgf : g ≤ f) (hfh : f ≤ h) : Tendsto f b (𝓝 a) := tendsto_of_tendsto_of_tendsto_of_le_of_le' hg hh (eventually_of_forall hgf) (eventually_of_forall hfh) #align tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_of_tendsto_of_tendsto_of_le_of_le theorem nhds_order_unbounded {a : α} (hu : ∃ u, a < u) (hl : ∃ l, l < a) : 𝓝 a = ⨅ (l) (_ : l < a) (u) (_ : a < u), 𝓟 (Ioo l u) := by simp only [nhds_eq_order, ← inf_biInf, ← biInf_inf, *, ← inf_principal, ← Ioi_inter_Iio]; rfl #align nhds_order_unbounded nhds_order_unbounded theorem tendsto_order_unbounded {f : β → α} {a : α} {x : Filter β} (hu : ∃ u, a < u) (hl : ∃ l, l < a) (h : ∀ l u, l < a → a < u → ∀ᶠ b in x, l < f b ∧ f b < u) : Tendsto f x (𝓝 a) := by simp only [nhds_order_unbounded hu hl, tendsto_iInf, tendsto_principal] exact fun l hl u => h l u hl #align tendsto_order_unbounded tendsto_order_unbounded end Preorder instance tendstoIxxNhdsWithin {α : Type*} [TopologicalSpace α] (a : α) {s t : Set α} {Ixx} [TendstoIxxClass Ixx (𝓝 a) (𝓝 a)] [TendstoIxxClass Ixx (𝓟 s) (𝓟 t)] : TendstoIxxClass Ixx (𝓝[s] a) (𝓝[t] a) := Filter.tendstoIxxClass_inf #align tendsto_Ixx_nhds_within tendstoIxxNhdsWithin instance tendstoIccClassNhdsPi {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] [∀ i, OrderTopology (α i)] (f : ∀ i, α i) : TendstoIxxClass Icc (𝓝 f) (𝓝 f) := by constructor conv in (𝓝 f).smallSets => rw [nhds_pi, Filter.pi] simp only [smallSets_iInf, smallSets_comap, tendsto_iInf, tendsto_lift', (· ∘ ·), mem_powerset_iff] intro i s hs have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f refine' (tendsto_lift'.1 ((this.comp tendsto_fst).Icc (this.comp tendsto_snd)) s hs).mono _ exact fun p hp g hg => hp ⟨hg.1 _, hg.2 _⟩ #align tendsto_Icc_class_nhds_pi tendstoIccClassNhdsPi -- porting note: new lemma theorem induced_topology_le_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) : induced f ‹TopologicalSpace β› ≤ Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_of_nhds_le_nhds fun x => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal, Ioi, Iio, ← hf] refine inf_le_inf (le_iInf₂ fun a ha => ?_) (le_iInf₂ fun a ha => ?_) exacts [iInf₂_le (f a) ha, iInf₂_le (f a) ha] -- porting note: new lemma theorem induced_topology_eq_preorder [Preorder α] [Preorder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a b x}, b < f a → ¬(b < f x) → ∃ y, y < a ∧ b ≤ f y) (H₂ : ∀ {a b x}, f a < b → ¬(f x < b) → ∃ y, a < y ∧ f y ≤ b) : induced f ‹TopologicalSpace β› = Preorder.topology α := by let _ := Preorder.topology α; have : OrderTopology α := ⟨rfl⟩ refine le_antisymm (induced_topology_le_preorder hf) ?_ refine le_of_nhds_le_nhds fun a => ?_ simp only [nhds_eq_order, nhds_induced, comap_inf, comap_iInf, comap_principal] refine inf_le_inf (le_iInf₂ fun b hb => ?_) (le_iInf₂ fun b hb => ?_) · rcases em (∃ x, ¬(b < f x)) with (⟨x, hx⟩ | hb) · rcases H₁ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => hyb.trans_lt (hf.2 hz)) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) · rcases em (∃ x, ¬(f x < b)) with (⟨x, hx⟩ | hb) · rcases H₂ hb hx with ⟨y, hya, hyb⟩ exact iInf₂_le_of_le y hya (principal_mono.2 fun z hz => (hf.2 hz).trans_le hyb) · push_neg at hb exact le_principal_iff.2 (univ_mem' hb) theorem induced_orderTopology' {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H₁ : ∀ {a x}, x < f a → ∃ b < a, x ≤ f b) (H₂ : ∀ {a x}, f a < x → ∃ b > a, f b ≤ x) : @OrderTopology _ (induced f ta) _ := let _ := induced f ta ⟨induced_topology_eq_preorder hf (fun h _ => H₁ h) (fun h _ => H₂ h)⟩ #align induced_order_topology' induced_orderTopology' theorem induced_orderTopology {α : Type u} {β : Type v} [Preorder α] [ta : TopologicalSpace β] [Preorder β] [OrderTopology β] (f : α → β) (hf : ∀ {x y}, f x < f y ↔ x < y) (H : ∀ {x y}, x < y → ∃ a, x < f a ∧ f a < y) : @OrderTopology _ (induced f ta) _ := induced_orderTopology' f (hf) (fun xa => let ⟨b, xb, ba⟩ := H xa; ⟨b, hf.1 ba, le_of_lt xb⟩) fun ax => let ⟨b, ab, bx⟩ := H ax; ⟨b, hf.1 ab, le_of_lt bx⟩ #align induced_order_topology induced_orderTopology /-- The topology induced by a strictly monotone function with order-connected range is the preorder topology. -/ nonrec theorem StrictMono.induced_topology_eq_preorder {α β : Type*} [LinearOrder α] [LinearOrder β] [t : TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : t.induced f = Preorder.topology α := by refine induced_topology_eq_preorder hf.lt_iff_lt (fun h₁ h₂ => ?_) fun h₁ h₂ => ?_ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨not_lt.1 h₂, h₁.le⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ · rcases hc.out (mem_range_self _) (mem_range_self _) ⟨h₁.le, not_lt.1 h₂⟩ with ⟨y, rfl⟩ exact ⟨y, hf.lt_iff_lt.1 h₁, le_rfl⟩ /-- A strictly monotone function between linear orders with order topology is a topological embedding provided that the range of `f` is order-connected. -/ theorem StrictMono.embedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β] [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β} (hf : StrictMono f) (hc : OrdConnected (range f)) : Embedding f := ⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩ /-- On a `Set.OrdConnected` subset of a linear order, the order topology for the restriction of the order is the same as the restriction to the subset of the order topology. -/ instance orderTopology_of_ordConnected {α : Type u} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {t : Set α} [ht : OrdConnected t] : OrderTopology t := ⟨(Subtype.strictMono_coe t).induced_topology_eq_preorder $ by rwa [← @Subtype.range_val _ t] at ht⟩ #align order_topology_of_ord_connected orderTopology_of_ordConnected theorem nhdsWithin_Ici_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≥] a = (⨅ (u) (_ : a < u), 𝓟 (Iio u)) ⊓ 𝓟 (Ici a) := by rw [nhdsWithin, nhds_eq_order] refine' le_antisymm (inf_le_inf_right _ inf_le_right) (le_inf (le_inf _ inf_le_left) inf_le_right) exact inf_le_right.trans (le_iInf₂ fun l hl => principal_mono.2 <| Ici_subset_Ioi.2 hl) #align nhds_within_Ici_eq'' nhdsWithin_Ici_eq'' theorem nhdsWithin_Iic_eq'' [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) : 𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) := nhdsWithin_Ici_eq'' (toDual a) #align nhds_within_Iic_eq'' nhdsWithin_Iic_eq'' theorem nhdsWithin_Ici_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by simp only [nhdsWithin_Ici_eq'', biInf_inf ha, inf_principal, Iio_inter_Ici] #align nhds_within_Ici_eq' nhdsWithin_Ici_eq' theorem nhdsWithin_Iic_eq' [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by simp only [nhdsWithin_Iic_eq'', biInf_inf ha, inf_principal, Ioi_inter_Iic] #align nhds_within_Iic_eq' nhdsWithin_Iic_eq' theorem nhdsWithin_Ici_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := (nhdsWithin_Ici_eq' ha).symm ▸ hasBasis_biInf_principal (fun b hb c hc => ⟨min b c, lt_min hb hc, Ico_subset_Ico_right (min_le_left _ _), Ico_subset_Ico_right (min_le_right _ _)⟩) ha #align nhds_within_Ici_basis' nhdsWithin_Ici_basis' theorem nhdsWithin_Iic_basis' [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α} (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by convert nhdsWithin_Ici_basis' (α := αᵒᵈ) ha using 2 exact dual_Ico.symm #align nhds_within_Iic_basis' nhdsWithin_Iic_basis' theorem nhdsWithin_Ici_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u := nhdsWithin_Ici_basis' (exists_gt a) #align nhds_within_Ici_basis nhdsWithin_Ici_basis theorem nhdsWithin_Iic_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := nhdsWithin_Iic_basis' (exists_lt a) #align nhds_within_Iic_basis nhdsWithin_Iic_basis theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] : 𝓝 (⊤ : α) = ⨅ (l) (h₂ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)] #align nhds_top_order nhds_top_order theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] : 𝓝 (⊥ : α) = ⨅ (l) (h₂ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)] #align nhds_bot_order nhds_bot_order theorem nhds_top_basis [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) fun a : α => Ioi a := by have : ∃ x : α, x < ⊤ := (exists_ne ⊤).imp fun x hx => hx.lt_top simpa only [Iic_top, nhdsWithin_univ, Ioc_top] using nhdsWithin_Iic_basis' this #align nhds_top_basis nhds_top_basis theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a := nhds_top_basis (α := αᵒᵈ) #align nhds_bot_basis nhds_bot_basis theorem nhds_top_basis_Ici [TopologicalSpace α] [LinearOrder α] [OrderTop α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊤).HasBasis (fun a : α => a < ⊤) Ici := nhds_top_basis.to_hasBasis (fun _a ha => let ⟨b, hab, hb⟩ := exists_between ha; ⟨b, hb, Ici_subset_Ioi.mpr hab⟩) fun a ha => ⟨a, ha, Ioi_subset_Ici_self⟩ #align nhds_top_basis_Ici nhds_top_basis_Ici theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α] [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic := nhds_top_basis_Ici (α := αᵒᵈ) #align nhds_bot_basis_Iic nhds_bot_basis_Iic theorem tendsto_nhds_top_mono [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ᶠ[l] g) : Tendsto g l (𝓝 ⊤) := by simp only [nhds_top_order, tendsto_iInf, tendsto_principal] at hf ⊢ intro x hx filter_upwards [hf x hx, hg] with _ using lt_of_lt_of_le #align tendsto_nhds_top_mono tendsto_nhds_top_mono theorem tendsto_nhds_bot_mono [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ᶠ[l] f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_top_mono (β := βᵒᵈ) hf hg #align tendsto_nhds_bot_mono tendsto_nhds_bot_mono theorem tendsto_nhds_top_mono' [TopologicalSpace β] [Preorder β] [OrderTop β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊤)) (hg : f ≤ g) : Tendsto g l (𝓝 ⊤) := tendsto_nhds_top_mono hf (eventually_of_forall hg) #align tendsto_nhds_top_mono' tendsto_nhds_top_mono' theorem tendsto_nhds_bot_mono' [TopologicalSpace β] [Preorder β] [OrderBot β] [OrderTopology β] {l : Filter α} {f g : α → β} (hf : Tendsto f l (𝓝 ⊥)) (hg : g ≤ f) : Tendsto g l (𝓝 ⊥) := tendsto_nhds_bot_mono hf (eventually_of_forall hg) #align tendsto_nhds_bot_mono' tendsto_nhds_bot_mono' section LinearOrder variable [TopologicalSpace α] [LinearOrder α] section OrderClosedTopology variable [OrderClosedTopology α] {a b : α} theorem eventually_le_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b := Iic_mem_nhds hab #align eventually_le_nhds eventually_le_nhds theorem eventually_lt_nhds (hab : a < b) : ∀ᶠ x in 𝓝 a, x < b := Iio_mem_nhds hab #align eventually_lt_nhds eventually_lt_nhds theorem eventually_ge_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b ≤ x := Ici_mem_nhds hab #align eventually_ge_nhds eventually_ge_nhds theorem eventually_gt_nhds (hab : b < a) : ∀ᶠ x in 𝓝 a, b < x := Ioi_mem_nhds hab #align eventually_gt_nhds eventually_gt_nhds end OrderClosedTopology section OrderTopology variable [OrderTopology α] theorem order_separated {a₁ a₂ : α} (h : a₁ < a₂) : ∃ u v : Set α, IsOpen u ∧ IsOpen v ∧ a₁ ∈ u ∧ a₂ ∈ v ∧ ∀ b₁ ∈ u, ∀ b₂ ∈ v, b₁ < b₂ := let ⟨x, hx, y, hy, h⟩ := h.exists_disjoint_Iio_Ioi ⟨Iio x, Ioi y, isOpen_gt' _, isOpen_lt' _, hx, hy, h⟩ #align order_separated order_separated -- see Note [lower instance priority] instance (priority := 100) OrderTopology.to_orderClosedTopology : OrderClosedTopology α where isClosed_le' := isOpen_compl_iff.1 <| isOpen_prod_iff.mpr fun a₁ a₂ (h : ¬a₁ ≤ a₂) => have h : a₂ < a₁ := lt_of_not_ge h let ⟨u, v, hu, hv, ha₁, ha₂, h⟩ := order_separated h ⟨v, u, hv, hu, ha₂, ha₁, fun ⟨b₁, b₂⟩ ⟨h₁, h₂⟩ => not_le_of_gt <| h b₂ h₂ b₁ h₁⟩ #align order_topology.to_order_closed_topology OrderTopology.to_orderClosedTopology theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) : ∃ l < a, Ioc l a ⊆ s := (nhdsWithin_Iic_basis' h).mem_iff.mp (nhdsWithin_le_nhds hs) #align exists_Ioc_subset_of_mem_nhds exists_Ioc_subset_of_mem_nhds theorem exists_Ioc_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {l : α} (hl : l < a) : ∃ l' ∈ Ico l a, Ioc l' a ⊆ s := let ⟨l', hl'a, hl's⟩ := exists_Ioc_subset_of_mem_nhds hs ⟨l, hl⟩ ⟨max l l', ⟨le_max_left _ _, max_lt hl hl'a⟩, (Ioc_subset_Ioc_left <| le_max_right _ _).trans hl's⟩ #align exists_Ioc_subset_of_mem_nhds' exists_Ioc_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds' {a : α} {s : Set α} (hs : s ∈ 𝓝 a) {u : α} (hu : a < u) : ∃ u' ∈ Ioc a u, Ico a u' ⊆ s := by simpa only [OrderDual.exists, exists_prop, dual_Ico, dual_Ioc] using exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual #align exists_Ico_subset_of_mem_nhds' exists_Ico_subset_of_mem_nhds' theorem exists_Ico_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ u, a < u) : ∃ u, a < u ∧ Ico a u ⊆ s := let ⟨_l', hl'⟩ := h; let ⟨l, hl⟩ := exists_Ico_subset_of_mem_nhds' hs hl' ⟨l, hl.1.1, hl.2⟩ #align exists_Ico_subset_of_mem_nhds exists_Ico_subset_of_mem_nhds theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Ici {a : α} {s : Set α} (hs : s ∈ 𝓝[≥] a) : ∃ b, a ≤ b ∧ Icc a b ∈ 𝓝[≥] a ∧ Icc a b ⊆ s := by rcases (em (IsMax a)).imp_right not_isMax_iff.mp with (ha | ha) · use a simpa [ha.Ici_eq] using hs · rcases (nhdsWithin_Ici_basis' ha).mem_iff.mp hs with ⟨b, hab, hbs⟩ rcases eq_empty_or_nonempty (Ioo a b) with (H | ⟨c, hac, hcb⟩) · have : Ico a b = Icc a a := by rw [← Icc_union_Ioo_eq_Ico le_rfl hab, H, union_empty] exact ⟨a, le_rfl, this ▸ ⟨Ico_mem_nhdsWithin_Ici' hab, hbs⟩⟩ · refine' ⟨c, hac.le, Icc_mem_nhdsWithin_Ici' hac, _⟩ exact (Icc_subset_Ico_right hcb).trans hbs #align exists_Icc_mem_subset_of_mem_nhds_within_Ici exists_Icc_mem_subset_of_mem_nhdsWithin_Ici theorem exists_Icc_mem_subset_of_mem_nhdsWithin_Iic {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) : ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by simpa only [dual_Icc, toDual.surjective.exists] using exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (α := αᵒᵈ) (a := toDual a) hs #align exists_Icc_mem_subset_of_mem_nhds_within_Iic exists_Icc_mem_subset_of_mem_nhdsWithin_Iic theorem exists_Icc_mem_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) : ∃ b c, a ∈ Icc b c ∧ Icc b c ∈ 𝓝 a ∧ Icc b c ⊆ s := by rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Iic (nhdsWithin_le_nhds hs) with ⟨b, hba, hb_nhds, hbs⟩ rcases exists_Icc_mem_subset_of_mem_nhdsWithin_Ici (nhdsWithin_le_nhds hs) with ⟨c, hac, hc_nhds, hcs⟩ refine' ⟨b, c, ⟨hba, hac⟩, _⟩ rw [← Icc_union_Icc_eq_Icc hba hac, ← nhds_left_sup_nhds_right] exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩ #align exists_Icc_mem_subset_of_mem_nhds exists_Icc_mem_subset_of_mem_nhds theorem IsOpen.exists_Ioo_subset [Nontrivial α] {s : Set α} (hs : IsOpen s) (h : s.Nonempty) : ∃ a b, a < b ∧ Ioo a b ⊆ s := by obtain ⟨x, hx⟩ : ∃ x, x ∈ s := h obtain ⟨y, hy⟩ : ∃ y, y ≠ x := exists_ne x rcases lt_trichotomy x y with (H | rfl | H) · obtain ⟨u, xu, hu⟩ : ∃ u, x < u ∧ Ico x u ⊆ s := exists_Ico_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨x, u, xu, Ioo_subset_Ico_self.trans hu⟩ · exact (hy rfl).elim · obtain ⟨l, lx, hl⟩ : ∃ l, l < x ∧ Ioc l x ⊆ s := exists_Ioc_subset_of_mem_nhds (hs.mem_nhds hx) ⟨y, H⟩ exact ⟨l, x, lx, Ioo_subset_Ioc_self.trans hl⟩ #align is_open.exists_Ioo_subset IsOpen.exists_Ioo_subset theorem dense_of_exists_between [Nontrivial α] {s : Set α} (h : ∀ ⦃a b⦄, a < b → ∃ c ∈ s, a < c ∧ c < b) : Dense s := by refine dense_iff_inter_open.2 fun U U_open U_nonempty => ?_ obtain ⟨a, b, hab, H⟩ : ∃ a b : α, a < b ∧ Ioo a b ⊆ U := U_open.exists_Ioo_subset U_nonempty obtain ⟨x, xs, hx⟩ : ∃ x ∈ s, a < x ∧ x < b := h hab exact ⟨x, ⟨H hx, xs⟩⟩ #align dense_of_exists_between dense_of_exists_between /-- A set in a nontrivial densely linear ordered type is dense in the sense of topology if and only if for any `a < b` there exists `c ∈ s`, `a < c < b`. Each implication requires less typeclass assumptions. -/ theorem dense_iff_exists_between [DenselyOrdered α] [Nontrivial α] {s : Set α} : Dense s ↔ ∀ a b, a < b → ∃ c ∈ s, a < c ∧ c < b := ⟨fun h _ _ hab => h.exists_between hab, dense_of_exists_between⟩ #align dense_iff_exists_between dense_iff_exists_between /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`, provided `a` is neither a bottom element nor a top element. -/ theorem mem_nhds_iff_exists_Ioo_subset' {a : α} {s : Set α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := by constructor · intro h rcases exists_Ico_subset_of_mem_nhds h hu with ⟨u, au, hu⟩ rcases exists_Ioc_subset_of_mem_nhds h hl with ⟨l, la, hl⟩ exact ⟨l, u, ⟨la, au⟩, Ioc_union_Ico_eq_Ioo la au ▸ union_subset hl hu⟩ · rintro ⟨l, u, ha, h⟩ apply mem_of_superset (Ioo_mem_nhds ha.1 ha.2) h #align mem_nhds_iff_exists_Ioo_subset' mem_nhds_iff_exists_Ioo_subset' /-- A set is a neighborhood of `a` if and only if it contains an interval `(l, u)` containing `a`. -/ theorem mem_nhds_iff_exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {s : Set α} : s ∈ 𝓝 a ↔ ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ s := mem_nhds_iff_exists_Ioo_subset' (exists_lt a) (exists_gt a) #align mem_nhds_iff_exists_Ioo_subset mem_nhds_iff_exists_Ioo_subset theorem nhds_basis_Ioo' {a : α} (hl : ∃ l, l < a) (hu : ∃ u, a < u) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := ⟨fun s => (mem_nhds_iff_exists_Ioo_subset' hl hu).trans <| by simp⟩ #align nhds_basis_Ioo' nhds_basis_Ioo' theorem nhds_basis_Ioo [NoMaxOrder α] [NoMinOrder α] (a : α) : (𝓝 a).HasBasis (fun b : α × α => b.1 < a ∧ a < b.2) fun b => Ioo b.1 b.2 := nhds_basis_Ioo' (exists_lt a) (exists_gt a) #align nhds_basis_Ioo nhds_basis_Ioo theorem Filter.Eventually.exists_Ioo_subset [NoMaxOrder α] [NoMinOrder α] {a : α} {p : α → Prop} (hp : ∀ᶠ x in 𝓝 a, p x) : ∃ l u, a ∈ Ioo l u ∧ Ioo l u ⊆ { x | p x } := mem_nhds_iff_exists_Ioo_subset.1 hp #align filter.eventually.exists_Ioo_subset Filter.Eventually.exists_Ioo_subset theorem Dense.topology_eq_generateFrom [DenselyOrdered α] {s : Set α} (hs : Dense s) : ‹TopologicalSpace α› = .generateFrom (Ioi '' s ∪ Iio '' s) := by refine (OrderTopology.topology_eq_generate_intervals (α := α)).trans ?_ refine le_antisymm (generateFrom_anti ?_) (le_generateFrom ?_) · simp only [union_subset_iff, image_subset_iff] exact ⟨fun a _ ↦ ⟨a, .inl rfl⟩, fun a _ ↦ ⟨a, .inr rfl⟩⟩ · rintro _ ⟨a, rfl | rfl⟩ · rw [hs.Ioi_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inl <| mem_image_of_mem _ h.1 · rw [hs.Iio_eq_biUnion] let _ := generateFrom (Ioi '' s ∪ Iio '' s) exact isOpen_iUnion fun x ↦ isOpen_iUnion fun h ↦ .basic _ <| .inr <| mem_image_of_mem _ h.1 variable (α) /-- Let `α` be a densely ordered linear order with order topology. If `α` is a separable space, then it has second countable topology. Note that the "densely ordered" assumption cannot be dropped, see [double arrow space](https://topology.pi-base.org/spaces/S000093) for a counterexample. -/ theorem SecondCountableTopology.of_separableSpace_orderTopology [DenselyOrdered α] [SeparableSpace α] : SecondCountableTopology α := by rcases exists_countable_dense α with ⟨s, hc, hd⟩ refine ⟨⟨_, ?_, hd.topology_eq_generateFrom⟩⟩ exact (hc.image _).union (hc.image _) variable {α} -- porting note: new lemma /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_covby_right [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x ⋖ y } := by nontriviality α let s := { x : α | ∃ y, x ⋖ y } have : ∀ x ∈ s, ∃ y, x ⋖ y := fun x => id choose! y hy using this have Hy : ∀ x z, x ∈ s → z < y x → z ≤ x := fun x z hx => (hy x hx).le_of_lt suffices H : ∀ a : Set α, IsOpen a → Set.Countable { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } · have : s ⊆ ⋃ a ∈ countableBasis α, { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a } := fun x hx => by rcases (isBasis_countableBasis α).exists_mem_of_ne (hy x hx).ne with ⟨a, ab, xa, ya⟩ exact mem_iUnion₂.2 ⟨a, ab, hx, xa, ya⟩ refine Set.Countable.mono this ?_ refine' Countable.biUnion (countable_countableBasis α) fun a ha => H _ _ exact isOpen_of_mem_countableBasis ha intro a ha suffices H : Set.Countable { x | (x ∈ s ∧ x ∈ a ∧ y x ∉ a) ∧ ¬IsBot x } · exact H.of_diff (subsingleton_isBot α).countable simp only [and_assoc] let t := { x | x ∈ s ∧ x ∈ a ∧ y x ∉ a ∧ ¬IsBot x } have : ∀ x ∈ t, ∃ z < x, Ioc z x ⊆ a := by intro x hx apply exists_Ioc_subset_of_mem_nhds (ha.mem_nhds hx.2.1) simpa only [IsBot, not_forall, not_le] using hx.right.right.right choose! z hz h'z using this have : PairwiseDisjoint t fun x => Ioc (z x) x := fun x xt x' x't hxx' => by rcases hxx'.lt_or_lt with (h' | h') · refine' disjoint_left.2 fun u ux ux' => xt.2.2.1 _ refine' h'z x' x't ⟨ux'.1.trans_le (ux.2.trans (hy x xt.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ xt.1 H).trans_lt h') · refine' disjoint_left.2 fun u ux ux' => x't.2.2.1 _ refine' h'z x xt ⟨ux.1.trans_le (ux'.2.trans (hy x' x't.1).le), _⟩ by_contra! H exact lt_irrefl _ ((Hy _ _ x't.1 H).trans_lt h') refine' this.countable_of_isOpen (fun x hx => _) fun x hx => ⟨x, hz x hx, le_rfl⟩ suffices H : Ioc (z x) x = Ioo (z x) (y x) · rw [H] exact isOpen_Ioo exact Subset.antisymm (Ioc_subset_Ioo_right (hy x hx.1).lt) fun u hu => ⟨hu.1, Hy _ _ hx.1 hu.2⟩ /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ @[deprecated countable_setOf_covby_right] theorem countable_of_isolated_right' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, x < y ∧ Ioo x y = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_right #align countable_of_isolated_right countable_of_isolated_right' /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_covby_left [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y ⋖ x } := by convert countable_setOf_covby_right (α := αᵒᵈ) using 5 exact toDual_covby_toDual_iff.symm /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_of_isolated_left' [SecondCountableTopology α] : Set.Countable { x : α | ∃ y, y < x ∧ Ioo y x = ∅ } := by simpa only [← covby_iff_Ioo_eq] using countable_setOf_covby_left #align countable_of_isolated_left countable_of_isolated_left' /-- Consider a disjoint family of intervals `(x, y)` with `x < y` in a second-countable space. Then the family is countable. This is not a straightforward consequence of second-countability as some of these intervals might be empty (but in fact this can happen only for countably many of them). -/ theorem Set.PairwiseDisjoint.countable_of_Ioo [SecondCountableTopology α] {y : α → α} {s : Set α} (h : PairwiseDisjoint s fun x => Ioo x (y x)) (h' : ∀ x ∈ s, x < y x) : s.Countable := have : (s \ { x | ∃ y, x ⋖ y }).Countable := (h.subset (diff_subset _ _)).countable_of_isOpen (fun _ _ => isOpen_Ioo) fun x hx => (h' _ hx.1).exists_lt_lt (mt (Exists.intro (y x)) hx.2) this.of_diff countable_setOf_covby_right #align set.pairwise_disjoint.countable_of_Ioo Set.PairwiseDisjoint.countable_of_Ioo /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} := by /- If the values of `f` are separated above on the right of `x`, there is an interval `(f x, z x)` which is not reached by `f`. This gives a family of disjoint open intervals in `α`. Such a family can only be countable as `α` is second-countable. -/ nontriviality β have : Nonempty α := Nonempty.map f (by infer_instance) let s := {x | ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y} have : ∀ x, x ∈ s → ∃ z, f x < z ∧ ∀ y, x < y → z ≤ f y := fun x hx ↦ hx -- choose `z x` such that `f` does not take the values in `(f x, z x)`. choose! z hz using this have I : InjOn f s := by apply StrictMonoOn.injOn intro x hx y _ hxy calc f x < z x := (hz x hx).1 _ ≤ f y := (hz x hx).2 y hxy -- show that `f s` is countable by arguing that a disjoint family of disjoint open intervals -- (the intervals `(f x, z x)`) is at most countable. have fs_count : (f '' s).Countable := by have A : (f '' s).PairwiseDisjoint fun x => Ioo x (z (invFunOn f s x)) := by rintro _ ⟨u, us, rfl⟩ _ ⟨v, vs, rfl⟩ huv wlog hle : u ≤ v generalizing u v · exact (this v vs u us huv.symm (le_of_not_le hle)).symm have hlt : u < v := hle.lt_of_ne (ne_of_apply_ne _ huv) apply disjoint_iff_forall_ne.2 rintro a ha b hb rfl simp only [I.leftInvOn_invFunOn us, I.leftInvOn_invFunOn vs] at ha hb exact lt_irrefl _ ((ha.2.trans_le ((hz u us).2 v hlt)).trans hb.1) apply Set.PairwiseDisjoint.countable_of_Ioo A rintro _ ⟨y, ys, rfl⟩ simpa only [I.leftInvOn_invFunOn ys] using (hz y ys).1 exact MapsTo.countable_of_injOn (mapsTo_image f s) I fs_count /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/ theorem countable_image_lt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, f x < z ∧ ∀ y, y < x → z ≤ f y} := countable_image_lt_image_Ioi (β := βᵒᵈ) f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated below from `f x` is countable. -/ theorem countable_image_gt_image_Iio [LinearOrder β] (f : β → α) [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, y < x → f y ≤ z} := countable_image_lt_image_Ioi (α := αᵒᵈ) (β := βᵒᵈ) f instance instIsCountablyGenerated_atTop [SecondCountableTopology α] : IsCountablyGenerated (atTop : Filter α) := by by_cases h : ∃ (x : α), IsTop x · rcases h with ⟨x, hx⟩ rw [atTop_eq_pure_of_isTop hx] exact isCountablyGenerated_pure x · rcases exists_countable_basis α with ⟨b, b_count, b_ne, hb⟩ have : Countable b := by exact Iff.mpr countable_coe_iff b_count have A : ∀ (s : b), ∃ (x : α), x ∈ (s : Set α) := by intro s have : (s : Set α) ≠ ∅ := by intro H apply b_ne convert s.2 exact H.symm exact Iff.mp nmem_singleton_empty this choose a ha using A have : (atTop : Filter α) = (generate (Ici '' (range a))) := by apply atTop_eq_generate_of_not_bddAbove intro ⟨x, hx⟩ simp only [IsTop, not_exists, not_forall, not_le] at h rcases h x with ⟨y, hy⟩ obtain ⟨s, sb, -, hs⟩ : ∃ s, s ∈ b ∧ y ∈ s ∧ s ⊆ Ioi x := hb.exists_subset_of_mem_open hy isOpen_Ioi have I : a ⟨s, sb⟩ ≤ x := hx (mem_range_self _) have J : x < a ⟨s, sb⟩ := hs (ha ⟨s, sb⟩) exact lt_irrefl _ (I.trans_lt J) rw [this] exact ⟨_, (countable_range _).image _, rfl⟩ instance instIsCountablyGenerated_atBot [SecondCountableTopology α] : IsCountablyGenerated (atBot : Filter α) := @instIsCountablyGenerated_atTop αᵒᵈ _ _ _ _ section Pi /-! ### Intervals in `Π i, π i` belong to `𝓝 x` For each lemma `pi_Ixx_mem_nhds` we add a non-dependent version `pi_Ixx_mem_nhds'` because sometimes Lean fails to unify different instances while trying to apply the dependent version to, e.g., `ι → ℝ`. -/ variable {ι : Type*} {π : ι → Type*} [Finite ι] [∀ i, LinearOrder (π i)] [∀ i, TopologicalSpace (π i)] [∀ i, OrderTopology (π i)] {a b x : ∀ i, π i} {a' b' x' : ι → α} theorem pi_Iic_mem_nhds (ha : ∀ i, x i < a i) : Iic a ∈ 𝓝 x := pi_univ_Iic a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Iic_mem_nhds (ha _) #align pi_Iic_mem_nhds pi_Iic_mem_nhds theorem pi_Iic_mem_nhds' (ha : ∀ i, x' i < a' i) : Iic a' ∈ 𝓝 x' := pi_Iic_mem_nhds ha #align pi_Iic_mem_nhds' pi_Iic_mem_nhds' theorem pi_Ici_mem_nhds (ha : ∀ i, a i < x i) : Ici a ∈ 𝓝 x := pi_univ_Ici a ▸ set_pi_mem_nhds (Set.toFinite _) fun _ _ => Ici_mem_nhds (ha _) #align pi_Ici_mem_nhds pi_Ici_mem_nhds theorem pi_Ici_mem_nhds' (ha : ∀ i, a' i < x' i) : Ici a' ∈ 𝓝 x' := pi_Ici_mem_nhds ha #align pi_Ici_mem_nhds' pi_Ici_mem_nhds' theorem pi_Icc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Icc a b ∈ 𝓝 x := pi_univ_Icc a b ▸ set_pi_mem_nhds finite_univ fun _ _ => Icc_mem_nhds (ha _) (hb _) #align pi_Icc_mem_nhds pi_Icc_mem_nhds theorem pi_Icc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Icc a' b' ∈ 𝓝 x' := pi_Icc_mem_nhds ha hb #align pi_Icc_mem_nhds' pi_Icc_mem_nhds' variable [Nonempty ι] theorem pi_Iio_mem_nhds (ha : ∀ i, x i < a i) : Iio a ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Iio_subset a) exact Iio_mem_nhds (ha i) #align pi_Iio_mem_nhds pi_Iio_mem_nhds theorem pi_Iio_mem_nhds' (ha : ∀ i, x' i < a' i) : Iio a' ∈ 𝓝 x' := pi_Iio_mem_nhds ha #align pi_Iio_mem_nhds' pi_Iio_mem_nhds' theorem pi_Ioi_mem_nhds (ha : ∀ i, a i < x i) : Ioi a ∈ 𝓝 x := @pi_Iio_mem_nhds ι (fun i => (π i)ᵒᵈ) _ _ _ _ _ _ _ ha #align pi_Ioi_mem_nhds pi_Ioi_mem_nhds theorem pi_Ioi_mem_nhds' (ha : ∀ i, a' i < x' i) : Ioi a' ∈ 𝓝 x' := pi_Ioi_mem_nhds ha #align pi_Ioi_mem_nhds' pi_Ioi_mem_nhds' theorem pi_Ioc_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioc a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioc_subset a b) exact Ioc_mem_nhds (ha i) (hb i) #align pi_Ioc_mem_nhds pi_Ioc_mem_nhds theorem pi_Ioc_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioc a' b' ∈ 𝓝 x' := pi_Ioc_mem_nhds ha hb #align pi_Ioc_mem_nhds' pi_Ioc_mem_nhds' theorem pi_Ico_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ico a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ico_subset a b) exact Ico_mem_nhds (ha i) (hb i) #align pi_Ico_mem_nhds pi_Ico_mem_nhds theorem pi_Ico_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ico a' b' ∈ 𝓝 x' := pi_Ico_mem_nhds ha hb #align pi_Ico_mem_nhds' pi_Ico_mem_nhds' theorem pi_Ioo_mem_nhds (ha : ∀ i, a i < x i) (hb : ∀ i, x i < b i) : Ioo a b ∈ 𝓝 x := by refine' mem_of_superset (set_pi_mem_nhds Set.finite_univ fun i _ => _) (pi_univ_Ioo_subset a b) exact Ioo_mem_nhds (ha i) (hb i) #align pi_Ioo_mem_nhds pi_Ioo_mem_nhds theorem pi_Ioo_mem_nhds' (ha : ∀ i, a' i < x' i) (hb : ∀ i, x' i < b' i) : Ioo a' b' ∈ 𝓝 x' := pi_Ioo_mem_nhds ha hb #align pi_Ioo_mem_nhds' pi_Ioo_mem_nhds' end Pi theorem disjoint_nhds_atTop [NoMaxOrder α] (x : α) : Disjoint (𝓝 x) atTop := by rcases exists_gt x with ⟨y, hy : x < y⟩ refine' disjoint_of_disjoint_of_mem _ (Iio_mem_nhds hy) (mem_atTop y) exact disjoint_left.mpr fun z => not_le.2 #align disjoint_nhds_at_top disjoint_nhds_atTop @[simp] theorem inf_nhds_atTop [NoMaxOrder α] (x : α) : 𝓝 x ⊓ atTop = ⊥ := disjoint_iff.1 (disjoint_nhds_atTop x) #align inf_nhds_at_top inf_nhds_atTop theorem disjoint_nhds_atBot [NoMinOrder α] (x : α) : Disjoint (𝓝 x) atBot := disjoint_nhds_atTop (α := αᵒᵈ) x #align disjoint_nhds_at_bot disjoint_nhds_atBot @[simp] theorem inf_nhds_atBot [NoMinOrder α] (x : α) : 𝓝 x ⊓ atBot = ⊥ := inf_nhds_atTop (α := αᵒᵈ) x #align inf_nhds_at_bot inf_nhds_atBot theorem not_tendsto_nhds_of_tendsto_atTop [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atTop) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atTop x).symm #align not_tendsto_nhds_of_tendsto_at_top not_tendsto_nhds_of_tendsto_atTop theorem not_tendsto_atTop_of_tendsto_nhds [NoMaxOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atTop := hf.not_tendsto (disjoint_nhds_atTop x) #align not_tendsto_at_top_of_tendsto_nhds not_tendsto_atTop_of_tendsto_nhds theorem not_tendsto_nhds_of_tendsto_atBot [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} (hf : Tendsto f F atBot) (x : α) : ¬Tendsto f F (𝓝 x) := hf.not_tendsto (disjoint_nhds_atBot x).symm #align not_tendsto_nhds_of_tendsto_at_bot not_tendsto_nhds_of_tendsto_atBot theorem not_tendsto_atBot_of_tendsto_nhds [NoMinOrder α] {F : Filter β} [NeBot F] {f : β → α} {x : α} (hf : Tendsto f F (𝓝 x)) : ¬Tendsto f F atBot := hf.not_tendsto (disjoint_nhds_atBot x) #align not_tendsto_at_bot_of_tendsto_nhds not_tendsto_atBot_of_tendsto_nhds /-! ### Neighborhoods to the left and to the right on an `OrderTopology` We've seen some properties of left and right neighborhood of a point in an `OrderClosedTopology`. In an `OrderTopology`, such neighborhoods can be characterized as the sets containing suitable intervals to the right or to the left of `a`. We give now these characterizations. -/ open List in /-- The following statements are equivalent: 0. `s` is a neighborhood of `a` within `(a, +∞)`; 1. `s` is a neighborhood of `a` within `(a, b]`; 2. `s` is a neighborhood of `a` within `(a, b)`; 3. `s` includes `(a, u)` for some `u ∈ (a, b]`; 4. `s` includes `(a, u)` for some `u > a`. -/ theorem TFAE_mem_nhdsWithin_Ioi {a b : α} (hab : a < b) (s : Set α) : TFAE [s ∈ 𝓝[>] a, s ∈ 𝓝[Ioc a b] a, s ∈ 𝓝[Ioo a b] a, ∃ u ∈ Ioc a b, Ioo a u ⊆ s, ∃ u ∈ Ioi a, Ioo a u ⊆ s] := by tfae_have 1 ↔ 2 · rw [nhdsWithin_Ioc_eq_nhdsWithin_Ioi hab] tfae_have 1 ↔ 3 · rw [nhdsWithin_Ioo_eq_nhdsWithin_Ioi hab] tfae_have 4 → 5 · exact fun ⟨u, umem, hu⟩ => ⟨u, umem.1, hu⟩ tfae_have 5 → 1 · rintro ⟨u, hau, hu⟩ exact mem_of_superset (Ioo_mem_nhdsWithin_Ioi ⟨le_refl a, hau⟩) hu tfae_have 1 → 4 · intro h rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.1 h with ⟨v, va, hv⟩ rcases exists_Ico_subset_of_mem_nhds' va hab with ⟨u, au, hu⟩ refine' ⟨u, au, fun x hx => _⟩ refine' hv ⟨hu ⟨le_of_lt hx.1, hx.2⟩, _⟩ exact hx.1 tfae_finish #align tfae_mem_nhds_within_Ioi TFAE_mem_nhdsWithin_Ioi theorem mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioc a u', Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 3 #align mem_nhds_within_Ioi_iff_exists_mem_Ioc_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_mem_Ioc_Ioo_subset /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u < u'`, provided `a` is not a top element. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' {a u' : α} {s : Set α} (hu' : a < u') : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := (TFAE_mem_nhdsWithin_Ioi hu' s).out 0 4 #align mem_nhds_within_Ioi_iff_exists_Ioo_subset' mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' theorem nhdsWithin_Ioi_basis' {a : α} (h : ∃ b, a < b) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := let ⟨_, h⟩ := h ⟨fun _ => mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' h⟩ lemma nhdsWithin_Ioi_basis [NoMaxOrder α] (a : α) : (𝓝[>] a).HasBasis (a < ·) (Ioo a) := nhdsWithin_Ioi_basis' <| exists_gt a theorem nhdsWithin_Ioi_eq_bot_iff {a : α} : 𝓝[>] a = ⊥ ↔ IsTop a ∨ ∃ b, a ⋖ b := by by_cases ha : IsTop a · simp [ha, ha.isMax.Ioi_eq] · simp only [ha, false_or] rw [isTop_iff_isMax, not_isMax_iff] at ha simp only [(nhdsWithin_Ioi_basis' ha).eq_bot_iff, covby_iff_Ioo_eq] /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u)` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioo_subset [NoMaxOrder α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioo a u ⊆ s := let ⟨_u', hu'⟩ := exists_gt a mem_nhdsWithin_Ioi_iff_exists_Ioo_subset' hu' #align mem_nhds_within_Ioi_iff_exists_Ioo_subset mem_nhdsWithin_Ioi_iff_exists_Ioo_subset /-- The set of points which are isolated on the right is countable when the space is second-countable. -/ theorem countable_setOf_isolated_right [SecondCountableTopology α] : { x : α | 𝓝[>] x = ⊥ }.Countable := by simp only [nhdsWithin_Ioi_eq_bot_iff, setOf_or] exact (subsingleton_isTop α).countable.union countable_setOf_covby_right /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOf_isolated_left [SecondCountableTopology α] : { x : α | 𝓝[<] x = ⊥ }.Countable := countable_setOf_isolated_right (α := αᵒᵈ) /-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s := by rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset] constructor · rintro ⟨u, au, as⟩
rcases exists_between au with ⟨v, hv⟩
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s := by rw [mem_nhdsWithin_Ioi_iff_exists_Ioo_subset] constructor · rintro ⟨u, au, as⟩
Mathlib.Topology.Order.Basic.1715_0.Npdof1X5b8sCkZ2
/-- A set is a neighborhood of `a` within `(a, +∞)` if and only if it contains an interval `(a, u]` with `a < u`. -/ theorem mem_nhdsWithin_Ioi_iff_exists_Ioc_subset [NoMaxOrder α] [DenselyOrdered α] {a : α} {s : Set α} : s ∈ 𝓝[>] a ↔ ∃ u ∈ Ioi a, Ioc a u ⊆ s
Mathlib_Topology_Order_Basic