[System] You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Topology.Order.LocalExtr).

[User]
Prove the following theorem. The retrieved context below may help.

```lean
theorem IsLocalMax.on (h : IsLocalMax f a) (s) : IsLocalMaxOn f s a
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMinOn (L49-L52)
def IsLocalMinOn :=
IsMinFilter f (𝓝[s] a) a

/-- `IsLocalMaxOn f s a` means that `f x ≤ f a` for all `x ∈ s` in some neighborhood of `a`. -/
```

-- snippet 2
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMaxOn (L53-L56)
def IsLocalMaxOn :=
IsMaxFilter f (𝓝[s] a) a

/-- `IsLocalExtrOn f s a` means `IsLocalMinOn f s a ∨ IsLocalMaxOn f s a`. -/
```

-- snippet 3
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtrOn (L57-L60)
def IsLocalExtrOn :=
IsExtrFilter f (𝓝[s] a) a

/-- `IsLocalMin f a` means that `f a ≤ f x` for all `x` in some neighborhood of `a`. -/
```

-- snippet 4
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMin (L61-L64)
def IsLocalMin :=
IsMinFilter f (𝓝 a) a

/-- `IsLocalMax f a` means that `f x ≤ f a` for all `x ∈ s` in some neighborhood of `a`. -/
```

-- snippet 5
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtr (L69-L73)
def IsLocalExtr :=
IsExtrFilter f (𝓝 a) a

variable {f s a}
```

-- snippet 6
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtrOn (L74-L77)
theorem IsLocalExtrOn.elim {p : Prop} :
    IsLocalExtrOn f s a → (IsLocalMinOn f s a → p) → (IsLocalMaxOn f s a → p) → p :=
Or.elim
```

-- snippet 7
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtr (L78-L83)
theorem IsLocalExtr.elim {p : Prop} :
    IsLocalExtr f a → (IsLocalMin f a → p) → (IsLocalMax f a → p) → p :=
Or.elim

/-! ### Restriction to (sub)sets -/
```

-- snippet 8
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMin (L84-L86)
theorem IsLocalMin.on (h : IsLocalMin f a) (s) : IsLocalMinOn f s a :=
h.filter_inf _
```

-- snippet 9
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtr (L90-L92)
theorem IsLocalExtr.on (h : IsLocalExtr f a) (s) : IsLocalExtrOn f s a :=
h.filter_inf _
```

-- snippet 10
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMinOn (L93-L96)
theorem IsLocalMinOn.on_subset {t : Set α} (hf : IsLocalMinOn f t a) (h : s ⊆ t) :
    IsLocalMinOn f s a :=
hf.filter_mono <| nhdsWithin_mono a h
```

-- snippet 11
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMaxOn (L97-L100)
theorem IsLocalMaxOn.on_subset {t : Set α} (hf : IsLocalMaxOn f t a) (h : s ⊆ t) :
    IsLocalMaxOn f s a :=
hf.filter_mono <| nhdsWithin_mono a h
```

-- snippet 12
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtrOn (L101-L104)
theorem IsLocalExtrOn.on_subset {t : Set α} (hf : IsLocalExtrOn f t a) (h : s ⊆ t) :
    IsLocalExtrOn f s a :=
hf.filter_mono <| nhdsWithin_mono a h
```

-- snippet 13
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMinOn (L105-L107)
theorem IsLocalMinOn.inter (hf : IsLocalMinOn f s a) (t) : IsLocalMinOn f (s ∩ t) a :=
hf.on_subset inter_subset_left
```

-- snippet 14
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMaxOn (L108-L110)
theorem IsLocalMaxOn.inter (hf : IsLocalMaxOn f s a) (t) : IsLocalMaxOn f (s ∩ t) a :=
hf.on_subset inter_subset_left
```

-- snippet 15
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtrOn (L111-L113)
theorem IsLocalExtrOn.inter (hf : IsLocalExtrOn f s a) (t) : IsLocalExtrOn f (s ∩ t) a :=
hf.on_subset inter_subset_left
```

-- snippet 16
```lean
-- Mathlib.Topology.Order.LocalExtr.IsMinOn (L114-L116)
theorem IsMinOn.localize (hf : IsMinOn f s a) : IsLocalMinOn f s a :=
hf.filter_mono <| inf_le_right
```

-- snippet 17
```lean
-- Mathlib.Topology.Order.LocalExtr.IsMaxOn (L117-L119)
theorem IsMaxOn.localize (hf : IsMaxOn f s a) : IsLocalMaxOn f s a :=
hf.filter_mono <| inf_le_right
```

-- snippet 18
```lean
-- Mathlib.Topology.Order.LocalExtr.IsExtrOn (L120-L122)
theorem IsExtrOn.localize (hf : IsExtrOn f s a) : IsLocalExtrOn f s a :=
hf.filter_mono <| inf_le_right
```

-- snippet 19
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMinOn (L123-L126)
theorem IsLocalMinOn.isLocalMin (hf : IsLocalMinOn f s a) (hs : s ∈ 𝓝 a) : IsLocalMin f a :=
have : 𝓝 a ≤ 𝓟 s := le_principal_iff.2 hs
  hf.filter_mono <| le_inf le_rfl this
```

-- snippet 20
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMaxOn (L127-L130)
theorem IsLocalMaxOn.isLocalMax (hf : IsLocalMaxOn f s a) (hs : s ∈ 𝓝 a) : IsLocalMax f a :=
have : 𝓝 a ≤ 𝓟 s := le_principal_iff.2 hs
  hf.filter_mono <| le_inf le_rfl this
```

-- snippet 21
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtrOn (L131-L133)
theorem IsLocalExtrOn.isLocalExtr (hf : IsLocalExtrOn f s a) (hs : s ∈ 𝓝 a) : IsLocalExtr f a :=
hf.elim (fun hf => (hf.isLocalMin hs).isExtr) fun hf => (hf.isLocalMax hs).isExtr
```

-- snippet 22
```lean
-- Mathlib.Topology.Order.LocalExtr.isLocalMinOn_univ_iff (L134-L136)
lemma isLocalMinOn_univ_iff : IsLocalMinOn f univ a ↔ IsLocalMin f a := by
simp only [IsLocalMinOn, IsLocalMin, nhdsWithin_univ]
```

-- snippet 23
```lean
-- Mathlib.Topology.Order.LocalExtr.isLocalMaxOn_univ_iff (L137-L139)
lemma isLocalMaxOn_univ_iff : IsLocalMaxOn f univ a ↔ IsLocalMax f a := by
simp only [IsLocalMaxOn, IsLocalMax, nhdsWithin_univ]
```

-- snippet 24
```lean
-- Mathlib.Topology.Order.LocalExtr.isLocalExtrOn_univ_iff (L140-L142)
lemma isLocalExtrOn_univ_iff : IsLocalExtrOn f univ a ↔ IsLocalExtr f a :=
isLocalMinOn_univ_iff.or isLocalMaxOn_univ_iff
```

-- snippet 25
```lean
-- Mathlib.Topology.Order.LocalExtr.IsMinOn (L143-L145)
theorem IsMinOn.isLocalMin (hf : IsMinOn f s a) (hs : s ∈ 𝓝 a) : IsLocalMin f a :=
hf.localize.isLocalMin hs
```

-- snippet 26
```lean
-- Mathlib.Topology.Order.Basic.tendstoIooClassNhds (L155-L160)
instance tendstoIooClassNhds [OrderTopology α] (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) :=
tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self

variable (α) in
/-- In a second countable topological space with the order topology, the topology is generated
by half-infinite open intervals with endpoints in a countable set. -/
```

-- snippet 27
```lean
-- Mathlib.Topology.Order.Basic.nhds_eq_order (L132-L137)
theorem nhds_eq_order [OrderTopology α] (a : α) :
    𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by
rw [OrderTopology.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]
```

-- snippet 28
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_Ioi_nhdsGT (L130-L133)
theorem comap_coe_Ioi_nhdsGT (a : X) (ha : IsPredPrelimit a := by exact .of_dense _) :
comap ((↑) : Ioi a → X) (𝓝[>] a) = atBot :=
  comap_coe_nhdsGT_of_Ioo_subset Subset.rfl (fun ⟨x, hx⟩ => ⟨x, hx, Ioo_subset_Ioi_self⟩) ha
```

-- snippet 29
```lean
-- Mathlib.Topology.Order.Basic.nhds_order_unbounded (L236-L239)
theorem nhds_order_unbounded [OrderTopology α] {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
```

-- snippet 30
```lean
-- Mathlib.Topology.Order.Basic.exists_Ioc_subset_of_mem_nhds (L442-L445)
theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) :
    ∃ l < a, Ioc l a ⊆ s :=
(nhdsLE_basis_of_exists_lt h).mem_iff.mp (nhdsWithin_le_nhds hs)
```

-- snippet 31
```lean
-- Mathlib.Topology.Order.Basic.isOpen_iff_generate_intervals (L106-L109)
theorem isOpen_iff_generate_intervals [t : OrderTopology α] {s : Set α} :
    IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by
rw [t.topology_eq_generate_intervals]; rfl
```

-- snippet 32
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_Ioi_atBot (L150-L153)
theorem map_coe_Ioi_atBot (a : X) (ha : IsPredPrelimit a := by exact .of_dense _) :
map ((↑) : Ioi a → X) atBot = 𝓝[>] a :=
  map_coe_atBot_of_Ioo_subset Subset.rfl (fun b hb => ⟨b, hb, Ioo_subset_Ioi_self⟩) ha
```

-- snippet 33
```lean
-- Mathlib.Topology.Order.Basic.gt_mem_nhds (L126-L128)
theorem gt_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b :=
(isOpen_gt' _).mem_nhds h
```

-- snippet 34
```lean
-- Mathlib.Topology.Order.Basic.exists_Ico_subset_of_mem_nhds (L457-L462)
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⟩
```

-- snippet 35
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_comp_coe_Ioo_atTop (L162-L165)
theorem tendsto_comp_coe_Ioo_atTop (h : a < b) (hb : IsSuccPrelimit b := by exact .of_dense _) :
Tendsto (fun x : Ioo a b => f x) atTop l ↔ Tendsto f (𝓝[<] b) l := by
  rw [← map_coe_Ioo_atTop h hb, tendsto_map'_iff, Function.comp_def]
```

-- snippet 36
```lean
-- Mathlib.Topology.Order.Basic.ge_mem_nhds (L129-L131)
theorem ge_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b :=
(gt_mem_nhds h).mono fun _ => le_of_lt
```

-- snippet 37
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_nhdsLT_of_Ioo_subset (L80-L89)
theorem comap_coe_nhdsLT_of_Ioo_subset (hsb : s ⊆ Iio b) (hs : s.Nonempty → ∃ a < b, Ioo a b ⊆ s)
    (hb : IsSuccPrelimit b := by exact .of_dense _) :
comap ((↑) : s → X) (𝓝[<] b) = atTop := by
  rw [comap_coe_nhdsLT_eq_atTop_iff]
  refine ⟨hsb, fun hsne a ha ↦ ?_⟩
  rcases hs hsne with ⟨c, hcb, hcs⟩
  rcases hb.lt_iff_exists_lt.mp (max_lt ha hcb) with ⟨x, hxb, hacx⟩
  rw [max_lt_iff] at hacx
  exact ⟨x, hcs ⟨hacx.2, hxb⟩, hacx.1, hxb⟩
```

-- snippet 38
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_atTop_of_Ioo_subset (L96-L105)
theorem map_coe_atTop_of_Ioo_subset (hsb : s ⊆ Iio b) (hs : ∀ a' < b, ∃ a < b, Ioo a b ⊆ s)
    (hb : IsSuccPrelimit b := by exact .of_dense _) :
map ((↑) : s → X) atTop = 𝓝[<] b := by
  rcases eq_empty_or_nonempty (Iio b) with (hb' | ⟨a, ha⟩)
  · have : IsEmpty s := ⟨fun x => hb'.subset (hsb x.2)⟩
    rw [filter_eq_bot_of_isEmpty atTop, Filter.map_bot, hb', nhdsWithin_empty]
  · rw [← comap_coe_nhdsLT_of_Ioo_subset hsb (fun _ => hs a ha) hb, map_comap_of_mem]
    rw [Subtype.range_val]
    exact (mem_nhdsLT_iff_exists_Ioo_subset' ha).2 (hs a ha)
```

-- snippet 39
```lean
-- Mathlib.Topology.Order.Basic.tendsto_nhds_top_mono' (L415-L418)
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)
```

-- snippet 40
```lean
-- Mathlib.Topology.Order.Basic.exists_countable_generateFrom_Ioi_Iio (L161-L182)
lemma exists_countable_generateFrom_Ioi_Iio
    [OrderTopology α] [SecondCountableTopology α] :
    ∃ (c : Set α), c.Countable ∧ ts = generateFrom { s | ∃ a ∈ c, s = Ioi a ∨ s = Iio a } := by
rcases isEmpty_or_nonempty α with hα | hα
  · exact ⟨∅, by simp, Subsingleton.elim _ _⟩
  obtain ⟨t, t_subs, t_count, ht⟩ : ∃ t ⊆ { s | ∃ a, s = Ioi a ∨ s = Iio a },
      t.Countable ∧ ts = generateFrom t :=
    exists_countable_of_generateFrom OrderTopology.topology_eq_generate_intervals
  have A : ∀ s ∈ t, ∃ a, s = Ioi a ∨ s = Iio a := t_subs
  choose! a ha using A
  refine ⟨a '' t, t_count.image _, ?_⟩
  apply le_antisymm
  · apply le_generateFrom_iff_subset_isOpen.2
    simp only [mem_image, exists_exists_and_eq_and, setOf_subset_setOf, forall_exists_index,
      and_imp]
    grind [isOpen_Iio', isOpen_Ioi']
  · rw [ht]
    apply generateFrom_anti
    grind

/-- If a topology is generated by half-open intervals with endpoints in a set `c`, then the sets
formed by intersecting finitely many of these intervals form a topological basis. -/
```

-- snippet 41
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_Ioo_atTop (L140-L143)
theorem map_coe_Ioo_atTop (h : a < b) (hb : IsSuccPrelimit b := by exact .of_dense _) :
map ((↑) : Ioo a b → X) atTop = 𝓝[<] b :=
  map_coe_atTop_of_Ioo_subset Ioo_subset_Iio_self (fun _ _ => ⟨_, h, Subset.rfl⟩) hb
```

-- snippet 42
```lean
-- Mathlib.Topology.Order.Basic.induced_topology_eq_preorder (L273-L293)
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 => ?_)
  · by_cases! h : ∃ x, ¬(b < f x)
    · rcases h with ⟨x, hx⟩
      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))
    · exact le_principal_iff.2 (univ_mem' h)
  · by_cases! h : ∃ x, ¬(f x < b)
    · rcases h with ⟨x, hx⟩
      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)
    · exact le_principal_iff.2 (univ_mem' h)
```

-- snippet 43
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_comp_coe_Ioo_atBot (L167-L170)
theorem tendsto_comp_coe_Ioo_atBot (h : a < b) (ha : IsPredPrelimit a := by exact .of_dense _) :
Tendsto (fun x : Ioo a b => f x) atBot l ↔ Tendsto f (𝓝[>] a) l := by
  rw [← map_coe_Ioo_atBot h ha, tendsto_map'_iff, Function.comp_def]
```

-- snippet 44
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_Iio_atTop (L155-L160)
theorem map_coe_Iio_atTop (a : X) (ha : IsSuccPrelimit a := by exact .of_dense _) :
map ((↑) : Iio a → X) atTop = 𝓝[<] a :=
  map_coe_Ioi_atBot (toDual a) ha.dual

variable {α : Type*} {l : Filter α} {f : X → α}
```

-- snippet 45
```lean
-- Mathlib.Topology.Order.Basic.tendstoIccClassNhdsPi (L253-L263)
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_eq_comap_image, tendsto_iInf, tendsto_comap_iff]
  intro i
  have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f
  refine (this.comp tendsto_fst).Icc (this.comp tendsto_snd) |>.smallSets_mono ?_
  filter_upwards [] using fun ⟨f, g⟩ ↦ image_subset_iff.mpr fun p hp ↦ ⟨hp.1 i, hp.2 i⟩
```

-- snippet 46
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_nhdsLT_eq_atTop_iff (L36-L72)
theorem comap_coe_nhdsLT_eq_atTop_iff :
    comap ((↑) : s → X) (𝓝[<] b) = atTop ↔
      s ⊆ Iio b ∧ (s.Nonempty → ∀ a < b, (s ∩ Ioo a b).Nonempty) := by
rcases s.eq_empty_or_nonempty with rfl | hsne
  · simp [eq_iff_true_of_subsingleton]
  have := hsne.to_subtype
  simp only [hsne, true_imp_iff]
  by_cases hsub : s ⊆ Iio b
  · simp only [hsub, true_and]
    constructor
    · intro h a ha
      have := preimage_mem_comap (m := ((↑) : s → X)) (Ioo_mem_nhdsLT ha)
      rw [h] at this
      rcases Filter.nonempty_of_mem this with ⟨⟨c, hcs⟩, hc⟩
      exact ⟨c, hcs, hc⟩
    · intro h
      refine (nhdsLT_basis_of_exists_lt (hsne.mono hsub)).comap _ |>.ext atTop_basis ?_ ?_
      · intro a hab
        rcases h a hab with ⟨c, hcs, hc⟩
        use ⟨c, hcs⟩
        simp_all [subset_def, hc.1.trans_le]
      · rintro ⟨a, has⟩ -
        use a, hsub has
        simp_all [subset_def, le_of_lt]
  · suffices ¬Tendsto (↑) (atTop : Filter s) (𝓝[<] b) by
      contrapose this
      simp_all [tendsto_iff_comap]
    intro h
    rcases not_subset_iff_exists_mem_notMem.mp hsub with ⟨a, has, ha⟩
    rcases h.eventually eventually_mem_nhdsWithin |>.and (eventually_ge_atTop ⟨a, has⟩) |>.exists
      with ⟨⟨c, hcs⟩, hcb, hac⟩
    apply lt_irrefl a
    calc
      a ≤ c := by simpa using hac
      _ < b := by simpa using hcb
      _ ≤ a := by simpa using ha
```

-- snippet 47
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_comp_coe_Iio_atTop (L177-L180)
theorem tendsto_comp_coe_Iio_atTop (ha : IsSuccPrelimit a := by exact .of_dense _) :
Tendsto (fun x : Iio a => f x) atTop l ↔ Tendsto f (𝓝[<] a) l := by
  rw [← map_coe_Iio_atTop a ha, tendsto_map'_iff, Function.comp_def]
```

-- snippet 48
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_Iio_nhdsLT (L135-L138)
theorem comap_coe_Iio_nhdsLT (a : X) (ha : IsSuccPrelimit a := by exact .of_dense _) :
comap ((↑) : Iio a → X) (𝓝[<] a) = atTop :=
  comap_coe_Ioi_nhdsGT (toDual a) ha.dual
```

-- snippet 49
```lean
-- Mathlib.Topology.Order.Basic.tendsto_nhds_bot_mono (L411-L414)
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
```

-- snippet 50
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_comp_coe_Ioi_atBot (L172-L175)
theorem tendsto_comp_coe_Ioi_atBot (ha : IsPredPrelimit a := by exact .of_dense _) :
Tendsto (fun x : Ioi a => f x) atBot l ↔ Tendsto f (𝓝[>] a) l := by
  rw [← map_coe_Ioi_atBot a ha, tendsto_map'_iff, Function.comp_def]
```

-- snippet 51
```lean
-- Mathlib.Topology.Order.Basic.nhds_bot_basis (L391-L394)
theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α]
    [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a :=
nhds_top_basis (α := αᵒᵈ)
```

-- snippet 52
```lean
-- Mathlib.Topology.Order.Basic.nhdsGE_basis (L372-L375)
theorem nhdsGE_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) :
    (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u :=
nhdsGE_basis_of_exists_gt (exists_gt a)
```

-- snippet 53
```lean
-- Mathlib.Topology.Order.Basic.lt_mem_nhds (L120-L122)
theorem lt_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x :=
(isOpen_lt' _).mem_nhds h
```

-- snippet 54
```lean
-- Mathlib.Topology.Order.Basic.isOpen_gt' (L115-L117)
theorem isOpen_gt' [OrderTopology α] (a : α) : IsOpen { b : α | b < a } :=
isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩
```

-- snippet 55
```lean
-- Mathlib.Topology.Order.Basic.le_mem_nhds (L123-L125)
theorem le_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x :=
(lt_mem_nhds h).mono fun _ => le_of_lt
```

-- snippet 56
```lean
-- Mathlib.Topology.Order.Basic.nhdsLE_eq_iInf_inf_principal (L346-L349)
theorem nhdsLE_eq_iInf_inf_principal [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) :
    𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) :=
nhdsGE_eq_iInf_inf_principal (toDual a)
```

-- snippet 57
```lean
-- Mathlib.Topology.Order.Basic.induced_orderTopology' (L294-L300)
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)⟩
```

-- snippet 58
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_Ioo_atBot (L187-L190)
theorem tendsto_Ioo_atBot {f : α → Ioo a b} (ha : IsPredPrelimit a := by exact .of_dense _) :
Tendsto f l atBot ↔ Tendsto (fun x => (f x : X)) l (𝓝[>] a) := by
  rw [← comap_coe_Ioo_nhdsGT a b ha, tendsto_comap_iff, Function.comp_def]
```

-- snippet 59
```lean
-- Mathlib.Topology.Order.Basic.nhdsLE_eq_iInf_principal (L354-L357)
theorem nhdsLE_eq_iInf_principal [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α}
    (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by
simp only [nhdsLE_eq_iInf_inf_principal, biInf_inf ha, inf_principal, Ioi_inter_Iic]
```

-- snippet 60
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_Ioi_atBot (L192-L195)
theorem tendsto_Ioi_atBot {f : α → Ioi a} (ha : IsPredPrelimit a := by exact .of_dense _) :
Tendsto f l atBot ↔ Tendsto (fun x => (f x : X)) l (𝓝[>] a) := by
  rw [← comap_coe_Ioi_nhdsGT a ha, tendsto_comap_iff, Function.comp_def]
```

-- snippet 61
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_Iio_atTop (L197-L199)
theorem tendsto_Iio_atTop {f : α → Iio a} (ha : IsSuccPrelimit a := by exact .of_dense _) :
Tendsto f l atTop ↔ Tendsto (fun x => (f x : X)) l (𝓝[<] a) := by
  rw [← comap_coe_Iio_nhdsLT a ha, tendsto_comap_iff, Function.comp_def]
```

-- snippet 62
```lean
-- Mathlib.Topology.Order.Basic.nhds_bot_order (L383-L385)
theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] :
    𝓝 (⊥ : α) = ⨅ (l) (_ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)]
```

-- snippet 63
```lean
-- Mathlib.Topology.Order.Basic.tendsto_nhds_top_mono (L405-L410)
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
```

-- snippet 64
```lean
-- Mathlib.Topology.Order.Basic.nhdsGE_eq_iInf_inf_principal (L340-L345)
theorem nhdsGE_eq_iInf_inf_principal [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)
```

-- snippet 65
```lean
-- Mathlib.Topology.Order.Basic.Preorder (L79-L86)
def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α :=
generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } }

section Preorder

variable [ts : TopologicalSpace α] [Preorder α]

/-- A countable preordered set equipped with the order topology is second countable. -/
```

-- snippet 66
```lean
-- Mathlib.Topology.Order.Basic.exists_Icc_mem_subset_of_mem_nhdsGE (L463-L474)
theorem exists_Icc_mem_subset_of_mem_nhdsGE {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 (nhdsGE_basis_of_exists_gt 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_nhdsGE hab, hbs⟩⟩
    · refine ⟨c, hac.le, Icc_mem_nhdsGE hac, ?_⟩
      exact (Icc_subset_Ico_right hcb).trans hbs
```

-- snippet 67
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_Ioo_nhdsLT (L116-L122)
theorem comap_coe_Ioo_nhdsLT (a b : X) (hb : IsSuccPrelimit b := by exact .of_dense _) :
comap ((↑) : Ioo a b → X) (𝓝[<] b) = atTop :=
  comap_coe_nhdsLT_of_Ioo_subset Ioo_subset_Iio_self
    (fun h => ⟨a, h.elim fun _x hx ↦ hx.1.trans hx.2, Subset.rfl⟩) hb

/-- The `atBot` filter for an open interval `Ioo a b` comes from the right-neighbourhoods filter at
the left endpoint in the ambient order. -/
```

-- snippet 68
```lean
-- Mathlib.Topology.Order.Basic.nhdsLE_basis (L376-L379)
theorem nhdsLE_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) :
    (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a :=
nhdsLE_basis_of_exists_lt (exists_lt a)
```

-- snippet 69
```lean
-- Mathlib.Topology.Order.Basic.isOpen_Iio' (L118-L119)
theorem isOpen_Iio' [OrderTopology α] (a : α) : IsOpen (Iio a) := isOpen_gt' a
```

-- snippet 70
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_nhdsGT_of_Ioo_subset (L90-L95)
theorem comap_coe_nhdsGT_of_Ioo_subset (hsa : s ⊆ Ioi a) (hs : s.Nonempty → ∃ b > a, Ioo a b ⊆ s)
    (ha : IsPredPrelimit a := by exact .of_dense _) :
comap ((↑) : s → X) (𝓝[>] a) = atBot := by
  refine comap_coe_nhdsLT_of_Ioo_subset (show ofDual ⁻¹' s ⊆ Iio (toDual a) from hsa) ?_ ha.dual
  simpa only [OrderDual.exists, Ioo_toDual]
```

-- snippet 71
```lean
-- Mathlib.Topology.Order.Basic.nhds_top_basis_Ici (L395-L400)
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⟩
```

-- snippet 72
```lean
-- Mathlib.Topology.Order.Basic.tendstoIccClassNhds (L141-L148)
instance tendstoIccClassNhds [OrderTopology α] (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]
```

-- snippet 73
```lean
-- Mathlib.Topology.Order.Basic.exists_Ico_subset_of_mem_nhds' (L452-L456)
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, Ico_toDual, Ioc_toDual] using
    exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual
```

-- snippet 74
```lean
-- Mathlib.Topology.Order.Basic.isOpen_Ioi' (L113-L114)
theorem isOpen_Ioi' [OrderTopology α] (a : α) : IsOpen (Ioi a) := isOpen_lt' a
```

-- snippet 75
```lean
-- Mathlib.Topology.Order.Basic.tendstoIcoClassNhds (L149-L151)
instance tendstoIcoClassNhds [OrderTopology α] (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) :=
tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self
```

-- snippet 76
```lean
-- Mathlib.Topology.Order.Basic.nhdsGE_eq_iInf_principal (L350-L353)
theorem nhdsGE_eq_iInf_principal [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α}
    (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by
simp only [nhdsGE_eq_iInf_inf_principal, biInf_inf ha, inf_principal, Iio_inter_Ici]
```

-- snippet 77
```lean
-- Mathlib.Topology.Order.Basic.nhds_bot_basis_Iic (L401-L404)
theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α]
    [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic :=
nhds_top_basis_Ici (α := αᵒᵈ)
```

-- snippet 78
```lean
-- Mathlib.Topology.Order.Basic.induced_topology_le_preorder (L264-L272)
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]
```

-- snippet 79
```lean
-- Mathlib.Topology.Order.Basic.order_separated (L430-L435)
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⟩

-- see Note [lower instance priority]
```

-- snippet 80
```lean
-- Mathlib.Topology.Order.Basic.isOpen_lt' (L110-L112)
theorem isOpen_lt' [OrderTopology α] (a : α) : IsOpen { b : α | a < b } :=
isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩
```

-- snippet 81
```lean
-- Mathlib.Topology.Order.Basic.nhds_top_basis (L386-L390)
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 nhdsLE_basis_of_exists_lt this
```

-- snippet 82
```lean
-- Mathlib.Topology.Order.Basic.tendsto_order (L138-L140)
theorem tendsto_order [OrderTopology α] {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
```

-- snippet 83
```lean
-- Mathlib.Topology.Order.Basic.nhdsGE_basis_of_exists_gt (L358-L366)
theorem nhdsGE_basis_of_exists_gt [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α}
    (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u :=
(nhdsGE_eq_iInf_principal 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

set_option backward.isDefEq.respectTransparency false in
```

-- snippet 84
```lean
-- Mathlib.Topology.Order.Basic.tendsto_of_tendsto_of_tendsto_of_le_of_le (L228-L235)
theorem tendsto_of_tendsto_of_tendsto_of_le_of_le [OrderTopology α] {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)

alias Filter.Tendsto.squeeze := tendsto_of_tendsto_of_tendsto_of_le_of_le
```

-- snippet 85
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_atBot_of_Ioo_subset (L106-L114)
theorem map_coe_atBot_of_Ioo_subset (hsa : s ⊆ Ioi a) (hs : ∀ b' > a, ∃ b > a, Ioo a b ⊆ s)
    (ha : IsPredPrelimit a := by exact .of_dense _) :
map ((↑) : s → X) atBot = 𝓝[>] a := by
  refine map_coe_atTop_of_Ioo_subset (s := ofDual ⁻¹' s) (b := toDual a) hsa ?_ ha.dual
  intro b' hb'
  simpa [OrderDual.exists] using hs (ofDual b') hb'

/-- The `atTop` filter for an open interval `Ioo a b` comes from the left-neighbourhoods filter at
the right endpoint in the ambient order. -/
```

-- snippet 86
```lean
-- Mathlib.Topology.Order.Basic.tendstoIocClassNhds (L152-L154)
instance tendstoIocClassNhds [OrderTopology α] (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) :=
tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self
```

-- snippet 87
```lean
-- Mathlib.Topology.Order.Basic.tendstoIxxNhdsWithin (L248-L252)
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
```

-- snippet 88
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_Ioo_atTop (L182-L185)
theorem tendsto_Ioo_atTop {f : α → Ioo a b} (hb : IsSuccPrelimit b := by exact .of_dense _) :
Tendsto f l atTop ↔ Tendsto (fun x => (f x : X)) l (𝓝[<] b) := by
  rw [← comap_coe_Ioo_nhdsLT a b hb, tendsto_comap_iff, Function.comp_def]
```

-- snippet 89
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_Ioo_atBot (L145-L148)
theorem map_coe_Ioo_atBot (h : a < b) (ha : IsPredPrelimit a := by exact .of_dense _) :
map ((↑) : Ioo a b → X) atBot = 𝓝[>] a :=
  map_coe_atBot_of_Ioo_subset Ioo_subset_Ioi_self (fun _ _ => ⟨_, h, Subset.rfl⟩) ha
```

-- snippet 90
```lean
-- Mathlib.Topology.Order.Basic.exists_Ioc_subset_of_mem_nhds' (L446-L451)
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⟩
```

-- snippet 91
```lean
-- Mathlib.Topology.Order.Basic.exists_Icc_mem_subset_of_mem_nhdsLE (L475-L479)
theorem exists_Icc_mem_subset_of_mem_nhdsLE {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) :
    ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by
simpa only [Icc_toDual, toDual.surjective.exists] using
    exists_Icc_mem_subset_of_mem_nhdsGE (α := αᵒᵈ) (a := toDual a) hs
```

-- snippet 92
```lean
-- Mathlib.Topology.Order.Basic.OrderEmbedding (L328-L334)
lemma OrderEmbedding.isEmbedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β]
    [TopologicalSpace α] [OrderTopology α] [TopologicalSpace β] [OrderTopology β]
    (f : α ↪o β) (hc : OrdConnected (range f)) : Topology.IsEmbedding f :=
f.strictMono.isEmbedding_of_ordConnected hc

/-- 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. -/
```

-- snippet 93
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_Ioo_nhdsGT (L124-L128)
theorem comap_coe_Ioo_nhdsGT (a b : X) (ha : IsPredPrelimit a := by exact .of_dense _) :
comap ((↑) : Ioo a b → X) (𝓝[>] a) = atBot :=
  comap_coe_nhdsGT_of_Ioo_subset Ioo_subset_Ioi_self
    (fun h => ⟨b, h.elim fun _x hx ↦ hx.1.trans hx.2, Subset.rfl⟩) ha
```

-- snippet 94
```lean
-- Mathlib.Topology.Order.Basic.nhds_top_order (L380-L382)
theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] :
    𝓝 (⊤ : α) = ⨅ (l) (_ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)]
```

-- snippet 95
```lean
-- Mathlib.Topology.Order.Basic.StrictMono (L321-L327)
theorem StrictMono.isEmbedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β]
    [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β}
    (hf : StrictMono f) (hc : OrdConnected (range f)) : IsEmbedding f :=
⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩

/-- An `OrderEmbedding` is a topological embedding provided that the range of `f` is
order-connected -/
```

-- snippet 96
```lean
-- Mathlib.Topology.Order.Basic.orderTopology_of_ordConnected (L335-L339)
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⟩
```

-- snippet 97
```lean
-- Mathlib.Topology.Order.Basic.exists_Icc_mem_subset_of_mem_nhds (L480-L489)
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_nhdsLE (nhdsWithin_le_nhds hs) with
    ⟨b, hba, hb_nhds, hbs⟩
  rcases exists_Icc_mem_subset_of_mem_nhdsGE (nhdsWithin_le_nhds hs) with
    ⟨c, hac, hc_nhds, hcs⟩
  refine ⟨b, c, ⟨hba, hac⟩, ?_⟩
  rw [← Icc_union_Icc_eq_Icc hba hac, ← nhdsLE_sup_nhdsGE]
  exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩
```

-- snippet 98
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_nhdsGT_eq_atBot_iff (L73-L79)
theorem comap_coe_nhdsGT_eq_atBot_iff :
    comap ((↑) : s → X) (𝓝[>] b) = atBot ↔
      s ⊆ Ioi b ∧ (s.Nonempty → ∀ a > b, (s ∩ Ioo b a).Nonempty) := by
refine comap_coe_nhdsLT_eq_atTop_iff (s := OrderDual.ofDual ⁻¹' s) (b := OrderDual.toDual b)
    |>.trans ?_
  simp [← preimage_inter, ofDual.surjective]
```

-- snippet 99
```lean
-- Mathlib.Topology.Order.Basic.IsOpen (L490-L502)
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⟩
```

-- snippet 100
```lean
-- Mathlib.Topology.Order.Basic.tendsto_of_tendsto_of_tendsto_of_le_of_le' (L219-L227)
theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' [OrderTopology α] {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

alias Filter.Tendsto.squeeze' := tendsto_of_tendsto_of_tendsto_of_le_of_le'

/-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities
hold everywhere. -/
```

-- snippet 101
```lean
-- Mathlib.Topology.Order.Basic.tendsto_nhds_bot_mono' (L419-L429)
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)

section LinearOrder

variable [TopologicalSpace α] [LinearOrder α]

section OrderTopology
variable [OrderTopology α]
```

-- snippet 102
```lean
-- Mathlib.Topology.Order.Basic.isTopologicalBasis_biInter_Ioi_Iio_of_generateFrom (L183-L218)
lemma isTopologicalBasis_biInter_Ioi_Iio_of_generateFrom (c : Set α)
    (h : ts = generateFrom { s | ∃ a ∈ c, s = Ioi a ∨ s = Iio a }) :
    IsTopologicalBasis {s | ∃ (f g : Set α), f ⊆ c ∧ g ⊆ c ∧ f.Finite ∧ g.Finite
      ∧ s = (⋂ a ∈ f, Ioi a) ∩ (⋂ a ∈ g, Iio a)} := by
refine IsTopologicalBasis.of_isOpen_of_subset ?_ (isTopologicalBasis_of_subbasis h) ?_
  · rintro u ⟨f, g, hfc, hgc, hf_fin, hg_fin, rfl⟩
    apply IsOpen.inter
    · apply hf_fin.isOpen_biInter (fun i hi ↦ ?_)
      rw [h]
      exact isOpen_generateFrom_of_mem ⟨i, hfc hi, Or.inl rfl⟩
    · apply hg_fin.isOpen_biInter (fun i hi ↦ ?_)
      rw [h]
      exact isOpen_generateFrom_of_mem ⟨i, hgc hi, Or.inr rfl⟩
  simp only [exists_and_left, image_subset_iff, preimage_setOf_eq, setOf_subset_setOf, and_imp]
  intro k k_fin hk
  let kl := {s ∈ k | ∃ a ∈ c, s = Ioi a}
  let kr := {s ∈ k | ∃ a ∈ c, s = Iio a}
  have k_eq : k = kl ∪ kr := by
    -- this `have` can be removed, but makes `grind` slower
    have : ∀ s ∈ k, ∃ a ∈ c, s = Ioi a ∨ s = Iio a := hk
    ext
    grind
  have : Finite kl := k_fin.subset (by simp [k_eq])
  have : Finite kr := k_fin.subset (by simp [k_eq])
  have Al : ∀ s : kl, ∃ a ∈ c, s = Ioi a := fun s ↦ s.2.2
  choose al alc hal using Al
  have Ar : ∀ s : kr, ∃ a ∈ c, s = Iio a := fun s ↦ s.2.2
  choose ar arc har using Ar
  refine ⟨range al, by simp [range_subset_iff, alc], range ar,
    by simp [range_subset_iff, arc], finite_range _, finite_range _, ?_⟩
  rw [k_eq, sInter_eq_biInter, biInter_union, biInter_range, biInter_range, biInter_eq_iInter,
    biInter_eq_iInter]
  simp [hal, har]

/-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities
hold eventually for the filter. -/
```

-- snippet 103
```lean
-- Mathlib.Topology.Order.Basic.tendsto_order_unbounded (L240-L247)
theorem tendsto_order_unbounded [OrderTopology α] {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

end Preorder
```

-- snippet 104
```lean
-- Mathlib.Topology.Order.Basic.nhdsLE_basis_of_exists_lt (L367-L371)
theorem nhdsLE_basis_of_exists_lt [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α}
    (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by
convert nhdsGE_basis_of_exists_gt (α := αᵒᵈ) ha using 2
  exact Ico_toDual.symm
```

-- snippet 105
```lean
-- Mathlib.Topology.Order.Basic.induced_orderTopology (L301-L320)
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⟩

/-- 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. -/
```

<s>[SYSTEM_PROMPT]You are Leanstral, a Lean 4 proof assistant. Complete the task below using the provided Lean source context. The target mathlib commit is 5e932f97dd25535344f80f9dd8da3aab83df0fe6 (module Mathlib.Topology.Order.LocalExtr).[/SYSTEM_PROMPT][MODEL_SETTINGS]{"reasoning_effort": "none"}[/MODEL_SETTINGS][INST]Prove the following theorem. The retrieved context below may help.

```lean
theorem IsLocalMax.on (h : IsLocalMax f a) (s) : IsLocalMaxOn f s a
```

## Retrieved context
-- snippet 1
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMinOn (L49-L52)
def IsLocalMinOn :=
IsMinFilter f (𝓝[s] a) a

/-- `IsLocalMaxOn f s a` means that `f x ≤ f a` for all `x ∈ s` in some neighborhood of `a`. -/
```

-- snippet 2
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMaxOn (L53-L56)
def IsLocalMaxOn :=
IsMaxFilter f (𝓝[s] a) a

/-- `IsLocalExtrOn f s a` means `IsLocalMinOn f s a ∨ IsLocalMaxOn f s a`. -/
```

-- snippet 3
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtrOn (L57-L60)
def IsLocalExtrOn :=
IsExtrFilter f (𝓝[s] a) a

/-- `IsLocalMin f a` means that `f a ≤ f x` for all `x` in some neighborhood of `a`. -/
```

-- snippet 4
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMin (L61-L64)
def IsLocalMin :=
IsMinFilter f (𝓝 a) a

/-- `IsLocalMax f a` means that `f x ≤ f a` for all `x ∈ s` in some neighborhood of `a`. -/
```

-- snippet 5
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtr (L69-L73)
def IsLocalExtr :=
IsExtrFilter f (𝓝 a) a

variable {f s a}
```

-- snippet 6
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtrOn (L74-L77)
theorem IsLocalExtrOn.elim {p : Prop} :
    IsLocalExtrOn f s a → (IsLocalMinOn f s a → p) → (IsLocalMaxOn f s a → p) → p :=
Or.elim
```

-- snippet 7
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtr (L78-L83)
theorem IsLocalExtr.elim {p : Prop} :
    IsLocalExtr f a → (IsLocalMin f a → p) → (IsLocalMax f a → p) → p :=
Or.elim

/-! ### Restriction to (sub)sets -/
```

-- snippet 8
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMin (L84-L86)
theorem IsLocalMin.on (h : IsLocalMin f a) (s) : IsLocalMinOn f s a :=
h.filter_inf _
```

-- snippet 9
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtr (L90-L92)
theorem IsLocalExtr.on (h : IsLocalExtr f a) (s) : IsLocalExtrOn f s a :=
h.filter_inf _
```

-- snippet 10
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMinOn (L93-L96)
theorem IsLocalMinOn.on_subset {t : Set α} (hf : IsLocalMinOn f t a) (h : s ⊆ t) :
    IsLocalMinOn f s a :=
hf.filter_mono <| nhdsWithin_mono a h
```

-- snippet 11
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMaxOn (L97-L100)
theorem IsLocalMaxOn.on_subset {t : Set α} (hf : IsLocalMaxOn f t a) (h : s ⊆ t) :
    IsLocalMaxOn f s a :=
hf.filter_mono <| nhdsWithin_mono a h
```

-- snippet 12
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtrOn (L101-L104)
theorem IsLocalExtrOn.on_subset {t : Set α} (hf : IsLocalExtrOn f t a) (h : s ⊆ t) :
    IsLocalExtrOn f s a :=
hf.filter_mono <| nhdsWithin_mono a h
```

-- snippet 13
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMinOn (L105-L107)
theorem IsLocalMinOn.inter (hf : IsLocalMinOn f s a) (t) : IsLocalMinOn f (s ∩ t) a :=
hf.on_subset inter_subset_left
```

-- snippet 14
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMaxOn (L108-L110)
theorem IsLocalMaxOn.inter (hf : IsLocalMaxOn f s a) (t) : IsLocalMaxOn f (s ∩ t) a :=
hf.on_subset inter_subset_left
```

-- snippet 15
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtrOn (L111-L113)
theorem IsLocalExtrOn.inter (hf : IsLocalExtrOn f s a) (t) : IsLocalExtrOn f (s ∩ t) a :=
hf.on_subset inter_subset_left
```

-- snippet 16
```lean
-- Mathlib.Topology.Order.LocalExtr.IsMinOn (L114-L116)
theorem IsMinOn.localize (hf : IsMinOn f s a) : IsLocalMinOn f s a :=
hf.filter_mono <| inf_le_right
```

-- snippet 17
```lean
-- Mathlib.Topology.Order.LocalExtr.IsMaxOn (L117-L119)
theorem IsMaxOn.localize (hf : IsMaxOn f s a) : IsLocalMaxOn f s a :=
hf.filter_mono <| inf_le_right
```

-- snippet 18
```lean
-- Mathlib.Topology.Order.LocalExtr.IsExtrOn (L120-L122)
theorem IsExtrOn.localize (hf : IsExtrOn f s a) : IsLocalExtrOn f s a :=
hf.filter_mono <| inf_le_right
```

-- snippet 19
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMinOn (L123-L126)
theorem IsLocalMinOn.isLocalMin (hf : IsLocalMinOn f s a) (hs : s ∈ 𝓝 a) : IsLocalMin f a :=
have : 𝓝 a ≤ 𝓟 s := le_principal_iff.2 hs
  hf.filter_mono <| le_inf le_rfl this
```

-- snippet 20
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalMaxOn (L127-L130)
theorem IsLocalMaxOn.isLocalMax (hf : IsLocalMaxOn f s a) (hs : s ∈ 𝓝 a) : IsLocalMax f a :=
have : 𝓝 a ≤ 𝓟 s := le_principal_iff.2 hs
  hf.filter_mono <| le_inf le_rfl this
```

-- snippet 21
```lean
-- Mathlib.Topology.Order.LocalExtr.IsLocalExtrOn (L131-L133)
theorem IsLocalExtrOn.isLocalExtr (hf : IsLocalExtrOn f s a) (hs : s ∈ 𝓝 a) : IsLocalExtr f a :=
hf.elim (fun hf => (hf.isLocalMin hs).isExtr) fun hf => (hf.isLocalMax hs).isExtr
```

-- snippet 22
```lean
-- Mathlib.Topology.Order.LocalExtr.isLocalMinOn_univ_iff (L134-L136)
lemma isLocalMinOn_univ_iff : IsLocalMinOn f univ a ↔ IsLocalMin f a := by
simp only [IsLocalMinOn, IsLocalMin, nhdsWithin_univ]
```

-- snippet 23
```lean
-- Mathlib.Topology.Order.LocalExtr.isLocalMaxOn_univ_iff (L137-L139)
lemma isLocalMaxOn_univ_iff : IsLocalMaxOn f univ a ↔ IsLocalMax f a := by
simp only [IsLocalMaxOn, IsLocalMax, nhdsWithin_univ]
```

-- snippet 24
```lean
-- Mathlib.Topology.Order.LocalExtr.isLocalExtrOn_univ_iff (L140-L142)
lemma isLocalExtrOn_univ_iff : IsLocalExtrOn f univ a ↔ IsLocalExtr f a :=
isLocalMinOn_univ_iff.or isLocalMaxOn_univ_iff
```

-- snippet 25
```lean
-- Mathlib.Topology.Order.LocalExtr.IsMinOn (L143-L145)
theorem IsMinOn.isLocalMin (hf : IsMinOn f s a) (hs : s ∈ 𝓝 a) : IsLocalMin f a :=
hf.localize.isLocalMin hs
```

-- snippet 26
```lean
-- Mathlib.Topology.Order.Basic.tendstoIooClassNhds (L155-L160)
instance tendstoIooClassNhds [OrderTopology α] (a : α) : TendstoIxxClass Ioo (𝓝 a) (𝓝 a) :=
tendstoIxxClass_of_subset fun _ _ => Ioo_subset_Icc_self

variable (α) in
/-- In a second countable topological space with the order topology, the topology is generated
by half-infinite open intervals with endpoints in a countable set. -/
```

-- snippet 27
```lean
-- Mathlib.Topology.Order.Basic.nhds_eq_order (L132-L137)
theorem nhds_eq_order [OrderTopology α] (a : α) :
    𝓝 a = (⨅ b ∈ Iio a, 𝓟 (Ioi b)) ⊓ ⨅ b ∈ Ioi a, 𝓟 (Iio b) := by
rw [OrderTopology.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]
```

-- snippet 28
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_Ioi_nhdsGT (L130-L133)
theorem comap_coe_Ioi_nhdsGT (a : X) (ha : IsPredPrelimit a := by exact .of_dense _) :
comap ((↑) : Ioi a → X) (𝓝[>] a) = atBot :=
  comap_coe_nhdsGT_of_Ioo_subset Subset.rfl (fun ⟨x, hx⟩ => ⟨x, hx, Ioo_subset_Ioi_self⟩) ha
```

-- snippet 29
```lean
-- Mathlib.Topology.Order.Basic.nhds_order_unbounded (L236-L239)
theorem nhds_order_unbounded [OrderTopology α] {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
```

-- snippet 30
```lean
-- Mathlib.Topology.Order.Basic.exists_Ioc_subset_of_mem_nhds (L442-L445)
theorem exists_Ioc_subset_of_mem_nhds {a : α} {s : Set α} (hs : s ∈ 𝓝 a) (h : ∃ l, l < a) :
    ∃ l < a, Ioc l a ⊆ s :=
(nhdsLE_basis_of_exists_lt h).mem_iff.mp (nhdsWithin_le_nhds hs)
```

-- snippet 31
```lean
-- Mathlib.Topology.Order.Basic.isOpen_iff_generate_intervals (L106-L109)
theorem isOpen_iff_generate_intervals [t : OrderTopology α] {s : Set α} :
    IsOpen s ↔ GenerateOpen { s | ∃ a, s = Ioi a ∨ s = Iio a } s := by
rw [t.topology_eq_generate_intervals]; rfl
```

-- snippet 32
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_Ioi_atBot (L150-L153)
theorem map_coe_Ioi_atBot (a : X) (ha : IsPredPrelimit a := by exact .of_dense _) :
map ((↑) : Ioi a → X) atBot = 𝓝[>] a :=
  map_coe_atBot_of_Ioo_subset Subset.rfl (fun b hb => ⟨b, hb, Ioo_subset_Ioi_self⟩) ha
```

-- snippet 33
```lean
-- Mathlib.Topology.Order.Basic.gt_mem_nhds (L126-L128)
theorem gt_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x < b :=
(isOpen_gt' _).mem_nhds h
```

-- snippet 34
```lean
-- Mathlib.Topology.Order.Basic.exists_Ico_subset_of_mem_nhds (L457-L462)
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⟩
```

-- snippet 35
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_comp_coe_Ioo_atTop (L162-L165)
theorem tendsto_comp_coe_Ioo_atTop (h : a < b) (hb : IsSuccPrelimit b := by exact .of_dense _) :
Tendsto (fun x : Ioo a b => f x) atTop l ↔ Tendsto f (𝓝[<] b) l := by
  rw [← map_coe_Ioo_atTop h hb, tendsto_map'_iff, Function.comp_def]
```

-- snippet 36
```lean
-- Mathlib.Topology.Order.Basic.ge_mem_nhds (L129-L131)
theorem ge_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 a, x ≤ b :=
(gt_mem_nhds h).mono fun _ => le_of_lt
```

-- snippet 37
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_nhdsLT_of_Ioo_subset (L80-L89)
theorem comap_coe_nhdsLT_of_Ioo_subset (hsb : s ⊆ Iio b) (hs : s.Nonempty → ∃ a < b, Ioo a b ⊆ s)
    (hb : IsSuccPrelimit b := by exact .of_dense _) :
comap ((↑) : s → X) (𝓝[<] b) = atTop := by
  rw [comap_coe_nhdsLT_eq_atTop_iff]
  refine ⟨hsb, fun hsne a ha ↦ ?_⟩
  rcases hs hsne with ⟨c, hcb, hcs⟩
  rcases hb.lt_iff_exists_lt.mp (max_lt ha hcb) with ⟨x, hxb, hacx⟩
  rw [max_lt_iff] at hacx
  exact ⟨x, hcs ⟨hacx.2, hxb⟩, hacx.1, hxb⟩
```

-- snippet 38
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_atTop_of_Ioo_subset (L96-L105)
theorem map_coe_atTop_of_Ioo_subset (hsb : s ⊆ Iio b) (hs : ∀ a' < b, ∃ a < b, Ioo a b ⊆ s)
    (hb : IsSuccPrelimit b := by exact .of_dense _) :
map ((↑) : s → X) atTop = 𝓝[<] b := by
  rcases eq_empty_or_nonempty (Iio b) with (hb' | ⟨a, ha⟩)
  · have : IsEmpty s := ⟨fun x => hb'.subset (hsb x.2)⟩
    rw [filter_eq_bot_of_isEmpty atTop, Filter.map_bot, hb', nhdsWithin_empty]
  · rw [← comap_coe_nhdsLT_of_Ioo_subset hsb (fun _ => hs a ha) hb, map_comap_of_mem]
    rw [Subtype.range_val]
    exact (mem_nhdsLT_iff_exists_Ioo_subset' ha).2 (hs a ha)
```

-- snippet 39
```lean
-- Mathlib.Topology.Order.Basic.tendsto_nhds_top_mono' (L415-L418)
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)
```

-- snippet 40
```lean
-- Mathlib.Topology.Order.Basic.exists_countable_generateFrom_Ioi_Iio (L161-L182)
lemma exists_countable_generateFrom_Ioi_Iio
    [OrderTopology α] [SecondCountableTopology α] :
    ∃ (c : Set α), c.Countable ∧ ts = generateFrom { s | ∃ a ∈ c, s = Ioi a ∨ s = Iio a } := by
rcases isEmpty_or_nonempty α with hα | hα
  · exact ⟨∅, by simp, Subsingleton.elim _ _⟩
  obtain ⟨t, t_subs, t_count, ht⟩ : ∃ t ⊆ { s | ∃ a, s = Ioi a ∨ s = Iio a },
      t.Countable ∧ ts = generateFrom t :=
    exists_countable_of_generateFrom OrderTopology.topology_eq_generate_intervals
  have A : ∀ s ∈ t, ∃ a, s = Ioi a ∨ s = Iio a := t_subs
  choose! a ha using A
  refine ⟨a '' t, t_count.image _, ?_⟩
  apply le_antisymm
  · apply le_generateFrom_iff_subset_isOpen.2
    simp only [mem_image, exists_exists_and_eq_and, setOf_subset_setOf, forall_exists_index,
      and_imp]
    grind [isOpen_Iio', isOpen_Ioi']
  · rw [ht]
    apply generateFrom_anti
    grind

/-- If a topology is generated by half-open intervals with endpoints in a set `c`, then the sets
formed by intersecting finitely many of these intervals form a topological basis. -/
```

-- snippet 41
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_Ioo_atTop (L140-L143)
theorem map_coe_Ioo_atTop (h : a < b) (hb : IsSuccPrelimit b := by exact .of_dense _) :
map ((↑) : Ioo a b → X) atTop = 𝓝[<] b :=
  map_coe_atTop_of_Ioo_subset Ioo_subset_Iio_self (fun _ _ => ⟨_, h, Subset.rfl⟩) hb
```

-- snippet 42
```lean
-- Mathlib.Topology.Order.Basic.induced_topology_eq_preorder (L273-L293)
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 => ?_)
  · by_cases! h : ∃ x, ¬(b < f x)
    · rcases h with ⟨x, hx⟩
      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))
    · exact le_principal_iff.2 (univ_mem' h)
  · by_cases! h : ∃ x, ¬(f x < b)
    · rcases h with ⟨x, hx⟩
      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)
    · exact le_principal_iff.2 (univ_mem' h)
```

-- snippet 43
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_comp_coe_Ioo_atBot (L167-L170)
theorem tendsto_comp_coe_Ioo_atBot (h : a < b) (ha : IsPredPrelimit a := by exact .of_dense _) :
Tendsto (fun x : Ioo a b => f x) atBot l ↔ Tendsto f (𝓝[>] a) l := by
  rw [← map_coe_Ioo_atBot h ha, tendsto_map'_iff, Function.comp_def]
```

-- snippet 44
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_Iio_atTop (L155-L160)
theorem map_coe_Iio_atTop (a : X) (ha : IsSuccPrelimit a := by exact .of_dense _) :
map ((↑) : Iio a → X) atTop = 𝓝[<] a :=
  map_coe_Ioi_atBot (toDual a) ha.dual

variable {α : Type*} {l : Filter α} {f : X → α}
```

-- snippet 45
```lean
-- Mathlib.Topology.Order.Basic.tendstoIccClassNhdsPi (L253-L263)
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_eq_comap_image, tendsto_iInf, tendsto_comap_iff]
  intro i
  have : Tendsto (fun g : ∀ i, α i => g i) (𝓝 f) (𝓝 (f i)) := (continuous_apply i).tendsto f
  refine (this.comp tendsto_fst).Icc (this.comp tendsto_snd) |>.smallSets_mono ?_
  filter_upwards [] using fun ⟨f, g⟩ ↦ image_subset_iff.mpr fun p hp ↦ ⟨hp.1 i, hp.2 i⟩
```

-- snippet 46
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_nhdsLT_eq_atTop_iff (L36-L72)
theorem comap_coe_nhdsLT_eq_atTop_iff :
    comap ((↑) : s → X) (𝓝[<] b) = atTop ↔
      s ⊆ Iio b ∧ (s.Nonempty → ∀ a < b, (s ∩ Ioo a b).Nonempty) := by
rcases s.eq_empty_or_nonempty with rfl | hsne
  · simp [eq_iff_true_of_subsingleton]
  have := hsne.to_subtype
  simp only [hsne, true_imp_iff]
  by_cases hsub : s ⊆ Iio b
  · simp only [hsub, true_and]
    constructor
    · intro h a ha
      have := preimage_mem_comap (m := ((↑) : s → X)) (Ioo_mem_nhdsLT ha)
      rw [h] at this
      rcases Filter.nonempty_of_mem this with ⟨⟨c, hcs⟩, hc⟩
      exact ⟨c, hcs, hc⟩
    · intro h
      refine (nhdsLT_basis_of_exists_lt (hsne.mono hsub)).comap _ |>.ext atTop_basis ?_ ?_
      · intro a hab
        rcases h a hab with ⟨c, hcs, hc⟩
        use ⟨c, hcs⟩
        simp_all [subset_def, hc.1.trans_le]
      · rintro ⟨a, has⟩ -
        use a, hsub has
        simp_all [subset_def, le_of_lt]
  · suffices ¬Tendsto (↑) (atTop : Filter s) (𝓝[<] b) by
      contrapose this
      simp_all [tendsto_iff_comap]
    intro h
    rcases not_subset_iff_exists_mem_notMem.mp hsub with ⟨a, has, ha⟩
    rcases h.eventually eventually_mem_nhdsWithin |>.and (eventually_ge_atTop ⟨a, has⟩) |>.exists
      with ⟨⟨c, hcs⟩, hcb, hac⟩
    apply lt_irrefl a
    calc
      a ≤ c := by simpa using hac
      _ < b := by simpa using hcb
      _ ≤ a := by simpa using ha
```

-- snippet 47
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_comp_coe_Iio_atTop (L177-L180)
theorem tendsto_comp_coe_Iio_atTop (ha : IsSuccPrelimit a := by exact .of_dense _) :
Tendsto (fun x : Iio a => f x) atTop l ↔ Tendsto f (𝓝[<] a) l := by
  rw [← map_coe_Iio_atTop a ha, tendsto_map'_iff, Function.comp_def]
```

-- snippet 48
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_Iio_nhdsLT (L135-L138)
theorem comap_coe_Iio_nhdsLT (a : X) (ha : IsSuccPrelimit a := by exact .of_dense _) :
comap ((↑) : Iio a → X) (𝓝[<] a) = atTop :=
  comap_coe_Ioi_nhdsGT (toDual a) ha.dual
```

-- snippet 49
```lean
-- Mathlib.Topology.Order.Basic.tendsto_nhds_bot_mono (L411-L414)
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
```

-- snippet 50
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_comp_coe_Ioi_atBot (L172-L175)
theorem tendsto_comp_coe_Ioi_atBot (ha : IsPredPrelimit a := by exact .of_dense _) :
Tendsto (fun x : Ioi a => f x) atBot l ↔ Tendsto f (𝓝[>] a) l := by
  rw [← map_coe_Ioi_atBot a ha, tendsto_map'_iff, Function.comp_def]
```

-- snippet 51
```lean
-- Mathlib.Topology.Order.Basic.nhds_bot_basis (L391-L394)
theorem nhds_bot_basis [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α]
    [Nontrivial α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) fun a : α => Iio a :=
nhds_top_basis (α := αᵒᵈ)
```

-- snippet 52
```lean
-- Mathlib.Topology.Order.Basic.nhdsGE_basis (L372-L375)
theorem nhdsGE_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMaxOrder α] (a : α) :
    (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u :=
nhdsGE_basis_of_exists_gt (exists_gt a)
```

-- snippet 53
```lean
-- Mathlib.Topology.Order.Basic.lt_mem_nhds (L120-L122)
theorem lt_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a < x :=
(isOpen_lt' _).mem_nhds h
```

-- snippet 54
```lean
-- Mathlib.Topology.Order.Basic.isOpen_gt' (L115-L117)
theorem isOpen_gt' [OrderTopology α] (a : α) : IsOpen { b : α | b < a } :=
isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inr rfl⟩
```

-- snippet 55
```lean
-- Mathlib.Topology.Order.Basic.le_mem_nhds (L123-L125)
theorem le_mem_nhds [OrderTopology α] {a b : α} (h : a < b) : ∀ᶠ x in 𝓝 b, a ≤ x :=
(lt_mem_nhds h).mono fun _ => le_of_lt
```

-- snippet 56
```lean
-- Mathlib.Topology.Order.Basic.nhdsLE_eq_iInf_inf_principal (L346-L349)
theorem nhdsLE_eq_iInf_inf_principal [TopologicalSpace α] [Preorder α] [OrderTopology α] (a : α) :
    𝓝[≤] a = (⨅ l < a, 𝓟 (Ioi l)) ⊓ 𝓟 (Iic a) :=
nhdsGE_eq_iInf_inf_principal (toDual a)
```

-- snippet 57
```lean
-- Mathlib.Topology.Order.Basic.induced_orderTopology' (L294-L300)
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)⟩
```

-- snippet 58
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_Ioo_atBot (L187-L190)
theorem tendsto_Ioo_atBot {f : α → Ioo a b} (ha : IsPredPrelimit a := by exact .of_dense _) :
Tendsto f l atBot ↔ Tendsto (fun x => (f x : X)) l (𝓝[>] a) := by
  rw [← comap_coe_Ioo_nhdsGT a b ha, tendsto_comap_iff, Function.comp_def]
```

-- snippet 59
```lean
-- Mathlib.Topology.Order.Basic.nhdsLE_eq_iInf_principal (L354-L357)
theorem nhdsLE_eq_iInf_principal [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α}
    (ha : ∃ l, l < a) : 𝓝[≤] a = ⨅ l < a, 𝓟 (Ioc l a) := by
simp only [nhdsLE_eq_iInf_inf_principal, biInf_inf ha, inf_principal, Ioi_inter_Iic]
```

-- snippet 60
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_Ioi_atBot (L192-L195)
theorem tendsto_Ioi_atBot {f : α → Ioi a} (ha : IsPredPrelimit a := by exact .of_dense _) :
Tendsto f l atBot ↔ Tendsto (fun x => (f x : X)) l (𝓝[>] a) := by
  rw [← comap_coe_Ioi_nhdsGT a ha, tendsto_comap_iff, Function.comp_def]
```

-- snippet 61
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_Iio_atTop (L197-L199)
theorem tendsto_Iio_atTop {f : α → Iio a} (ha : IsSuccPrelimit a := by exact .of_dense _) :
Tendsto f l atTop ↔ Tendsto (fun x => (f x : X)) l (𝓝[<] a) := by
  rw [← comap_coe_Iio_nhdsLT a ha, tendsto_comap_iff, Function.comp_def]
```

-- snippet 62
```lean
-- Mathlib.Topology.Order.Basic.nhds_bot_order (L383-L385)
theorem nhds_bot_order [TopologicalSpace α] [Preorder α] [OrderBot α] [OrderTopology α] :
    𝓝 (⊥ : α) = ⨅ (l) (_ : ⊥ < l), 𝓟 (Iio l) := by simp [nhds_eq_order (⊥ : α)]
```

-- snippet 63
```lean
-- Mathlib.Topology.Order.Basic.tendsto_nhds_top_mono (L405-L410)
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
```

-- snippet 64
```lean
-- Mathlib.Topology.Order.Basic.nhdsGE_eq_iInf_inf_principal (L340-L345)
theorem nhdsGE_eq_iInf_inf_principal [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)
```

-- snippet 65
```lean
-- Mathlib.Topology.Order.Basic.Preorder (L79-L86)
def Preorder.topology (α : Type*) [Preorder α] : TopologicalSpace α :=
generateFrom { s : Set α | ∃ a : α, s = { b : α | a < b } ∨ s = { b : α | b < a } }

section Preorder

variable [ts : TopologicalSpace α] [Preorder α]

/-- A countable preordered set equipped with the order topology is second countable. -/
```

-- snippet 66
```lean
-- Mathlib.Topology.Order.Basic.exists_Icc_mem_subset_of_mem_nhdsGE (L463-L474)
theorem exists_Icc_mem_subset_of_mem_nhdsGE {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 (nhdsGE_basis_of_exists_gt 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_nhdsGE hab, hbs⟩⟩
    · refine ⟨c, hac.le, Icc_mem_nhdsGE hac, ?_⟩
      exact (Icc_subset_Ico_right hcb).trans hbs
```

-- snippet 67
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_Ioo_nhdsLT (L116-L122)
theorem comap_coe_Ioo_nhdsLT (a b : X) (hb : IsSuccPrelimit b := by exact .of_dense _) :
comap ((↑) : Ioo a b → X) (𝓝[<] b) = atTop :=
  comap_coe_nhdsLT_of_Ioo_subset Ioo_subset_Iio_self
    (fun h => ⟨a, h.elim fun _x hx ↦ hx.1.trans hx.2, Subset.rfl⟩) hb

/-- The `atBot` filter for an open interval `Ioo a b` comes from the right-neighbourhoods filter at
the left endpoint in the ambient order. -/
```

-- snippet 68
```lean
-- Mathlib.Topology.Order.Basic.nhdsLE_basis (L376-L379)
theorem nhdsLE_basis [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [NoMinOrder α] (a : α) :
    (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a :=
nhdsLE_basis_of_exists_lt (exists_lt a)
```

-- snippet 69
```lean
-- Mathlib.Topology.Order.Basic.isOpen_Iio' (L118-L119)
theorem isOpen_Iio' [OrderTopology α] (a : α) : IsOpen (Iio a) := isOpen_gt' a
```

-- snippet 70
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_nhdsGT_of_Ioo_subset (L90-L95)
theorem comap_coe_nhdsGT_of_Ioo_subset (hsa : s ⊆ Ioi a) (hs : s.Nonempty → ∃ b > a, Ioo a b ⊆ s)
    (ha : IsPredPrelimit a := by exact .of_dense _) :
comap ((↑) : s → X) (𝓝[>] a) = atBot := by
  refine comap_coe_nhdsLT_of_Ioo_subset (show ofDual ⁻¹' s ⊆ Iio (toDual a) from hsa) ?_ ha.dual
  simpa only [OrderDual.exists, Ioo_toDual]
```

-- snippet 71
```lean
-- Mathlib.Topology.Order.Basic.nhds_top_basis_Ici (L395-L400)
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⟩
```

-- snippet 72
```lean
-- Mathlib.Topology.Order.Basic.tendstoIccClassNhds (L141-L148)
instance tendstoIccClassNhds [OrderTopology α] (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]
```

-- snippet 73
```lean
-- Mathlib.Topology.Order.Basic.exists_Ico_subset_of_mem_nhds' (L452-L456)
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, Ico_toDual, Ioc_toDual] using
    exists_Ioc_subset_of_mem_nhds' (show ofDual ⁻¹' s ∈ 𝓝 (toDual a) from hs) hu.dual
```

-- snippet 74
```lean
-- Mathlib.Topology.Order.Basic.isOpen_Ioi' (L113-L114)
theorem isOpen_Ioi' [OrderTopology α] (a : α) : IsOpen (Ioi a) := isOpen_lt' a
```

-- snippet 75
```lean
-- Mathlib.Topology.Order.Basic.tendstoIcoClassNhds (L149-L151)
instance tendstoIcoClassNhds [OrderTopology α] (a : α) : TendstoIxxClass Ico (𝓝 a) (𝓝 a) :=
tendstoIxxClass_of_subset fun _ _ => Ico_subset_Icc_self
```

-- snippet 76
```lean
-- Mathlib.Topology.Order.Basic.nhdsGE_eq_iInf_principal (L350-L353)
theorem nhdsGE_eq_iInf_principal [TopologicalSpace α] [Preorder α] [OrderTopology α] {a : α}
    (ha : ∃ u, a < u) : 𝓝[≥] a = ⨅ (u) (_ : a < u), 𝓟 (Ico a u) := by
simp only [nhdsGE_eq_iInf_inf_principal, biInf_inf ha, inf_principal, Iio_inter_Ici]
```

-- snippet 77
```lean
-- Mathlib.Topology.Order.Basic.nhds_bot_basis_Iic (L401-L404)
theorem nhds_bot_basis_Iic [TopologicalSpace α] [LinearOrder α] [OrderBot α] [OrderTopology α]
    [Nontrivial α] [DenselyOrdered α] : (𝓝 ⊥).HasBasis (fun a : α => ⊥ < a) Iic :=
nhds_top_basis_Ici (α := αᵒᵈ)
```

-- snippet 78
```lean
-- Mathlib.Topology.Order.Basic.induced_topology_le_preorder (L264-L272)
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]
```

-- snippet 79
```lean
-- Mathlib.Topology.Order.Basic.order_separated (L430-L435)
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⟩

-- see Note [lower instance priority]
```

-- snippet 80
```lean
-- Mathlib.Topology.Order.Basic.isOpen_lt' (L110-L112)
theorem isOpen_lt' [OrderTopology α] (a : α) : IsOpen { b : α | a < b } :=
isOpen_iff_generate_intervals.2 <| .basic _ ⟨a, .inl rfl⟩
```

-- snippet 81
```lean
-- Mathlib.Topology.Order.Basic.nhds_top_basis (L386-L390)
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 nhdsLE_basis_of_exists_lt this
```

-- snippet 82
```lean
-- Mathlib.Topology.Order.Basic.tendsto_order (L138-L140)
theorem tendsto_order [OrderTopology α] {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
```

-- snippet 83
```lean
-- Mathlib.Topology.Order.Basic.nhdsGE_basis_of_exists_gt (L358-L366)
theorem nhdsGE_basis_of_exists_gt [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α}
    (ha : ∃ u, a < u) : (𝓝[≥] a).HasBasis (fun u => a < u) fun u => Ico a u :=
(nhdsGE_eq_iInf_principal 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

set_option backward.isDefEq.respectTransparency false in
```

-- snippet 84
```lean
-- Mathlib.Topology.Order.Basic.tendsto_of_tendsto_of_tendsto_of_le_of_le (L228-L235)
theorem tendsto_of_tendsto_of_tendsto_of_le_of_le [OrderTopology α] {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)

alias Filter.Tendsto.squeeze := tendsto_of_tendsto_of_tendsto_of_le_of_le
```

-- snippet 85
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_atBot_of_Ioo_subset (L106-L114)
theorem map_coe_atBot_of_Ioo_subset (hsa : s ⊆ Ioi a) (hs : ∀ b' > a, ∃ b > a, Ioo a b ⊆ s)
    (ha : IsPredPrelimit a := by exact .of_dense _) :
map ((↑) : s → X) atBot = 𝓝[>] a := by
  refine map_coe_atTop_of_Ioo_subset (s := ofDual ⁻¹' s) (b := toDual a) hsa ?_ ha.dual
  intro b' hb'
  simpa [OrderDual.exists] using hs (ofDual b') hb'

/-- The `atTop` filter for an open interval `Ioo a b` comes from the left-neighbourhoods filter at
the right endpoint in the ambient order. -/
```

-- snippet 86
```lean
-- Mathlib.Topology.Order.Basic.tendstoIocClassNhds (L152-L154)
instance tendstoIocClassNhds [OrderTopology α] (a : α) : TendstoIxxClass Ioc (𝓝 a) (𝓝 a) :=
tendstoIxxClass_of_subset fun _ _ => Ioc_subset_Icc_self
```

-- snippet 87
```lean
-- Mathlib.Topology.Order.Basic.tendstoIxxNhdsWithin (L248-L252)
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
```

-- snippet 88
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.tendsto_Ioo_atTop (L182-L185)
theorem tendsto_Ioo_atTop {f : α → Ioo a b} (hb : IsSuccPrelimit b := by exact .of_dense _) :
Tendsto f l atTop ↔ Tendsto (fun x => (f x : X)) l (𝓝[<] b) := by
  rw [← comap_coe_Ioo_nhdsLT a b hb, tendsto_comap_iff, Function.comp_def]
```

-- snippet 89
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.map_coe_Ioo_atBot (L145-L148)
theorem map_coe_Ioo_atBot (h : a < b) (ha : IsPredPrelimit a := by exact .of_dense _) :
map ((↑) : Ioo a b → X) atBot = 𝓝[>] a :=
  map_coe_atBot_of_Ioo_subset Ioo_subset_Ioi_self (fun _ _ => ⟨_, h, Subset.rfl⟩) ha
```

-- snippet 90
```lean
-- Mathlib.Topology.Order.Basic.exists_Ioc_subset_of_mem_nhds' (L446-L451)
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⟩
```

-- snippet 91
```lean
-- Mathlib.Topology.Order.Basic.exists_Icc_mem_subset_of_mem_nhdsLE (L475-L479)
theorem exists_Icc_mem_subset_of_mem_nhdsLE {a : α} {s : Set α} (hs : s ∈ 𝓝[≤] a) :
    ∃ b ≤ a, Icc b a ∈ 𝓝[≤] a ∧ Icc b a ⊆ s := by
simpa only [Icc_toDual, toDual.surjective.exists] using
    exists_Icc_mem_subset_of_mem_nhdsGE (α := αᵒᵈ) (a := toDual a) hs
```

-- snippet 92
```lean
-- Mathlib.Topology.Order.Basic.OrderEmbedding (L328-L334)
lemma OrderEmbedding.isEmbedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β]
    [TopologicalSpace α] [OrderTopology α] [TopologicalSpace β] [OrderTopology β]
    (f : α ↪o β) (hc : OrdConnected (range f)) : Topology.IsEmbedding f :=
f.strictMono.isEmbedding_of_ordConnected hc

/-- 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. -/
```

-- snippet 93
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_Ioo_nhdsGT (L124-L128)
theorem comap_coe_Ioo_nhdsGT (a b : X) (ha : IsPredPrelimit a := by exact .of_dense _) :
comap ((↑) : Ioo a b → X) (𝓝[>] a) = atBot :=
  comap_coe_nhdsGT_of_Ioo_subset Ioo_subset_Ioi_self
    (fun h => ⟨b, h.elim fun _x hx ↦ hx.1.trans hx.2, Subset.rfl⟩) ha
```

-- snippet 94
```lean
-- Mathlib.Topology.Order.Basic.nhds_top_order (L380-L382)
theorem nhds_top_order [TopologicalSpace α] [Preorder α] [OrderTop α] [OrderTopology α] :
    𝓝 (⊤ : α) = ⨅ (l) (_ : l < ⊤), 𝓟 (Ioi l) := by simp [nhds_eq_order (⊤ : α)]
```

-- snippet 95
```lean
-- Mathlib.Topology.Order.Basic.StrictMono (L321-L327)
theorem StrictMono.isEmbedding_of_ordConnected {α β : Type*} [LinearOrder α] [LinearOrder β]
    [TopologicalSpace α] [h : OrderTopology α] [TopologicalSpace β] [OrderTopology β] {f : α → β}
    (hf : StrictMono f) (hc : OrdConnected (range f)) : IsEmbedding f :=
⟨⟨h.1.trans <| Eq.symm <| hf.induced_topology_eq_preorder hc⟩, hf.injective⟩

/-- An `OrderEmbedding` is a topological embedding provided that the range of `f` is
order-connected -/
```

-- snippet 96
```lean
-- Mathlib.Topology.Order.Basic.orderTopology_of_ordConnected (L335-L339)
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⟩
```

-- snippet 97
```lean
-- Mathlib.Topology.Order.Basic.exists_Icc_mem_subset_of_mem_nhds (L480-L489)
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_nhdsLE (nhdsWithin_le_nhds hs) with
    ⟨b, hba, hb_nhds, hbs⟩
  rcases exists_Icc_mem_subset_of_mem_nhdsGE (nhdsWithin_le_nhds hs) with
    ⟨c, hac, hc_nhds, hcs⟩
  refine ⟨b, c, ⟨hba, hac⟩, ?_⟩
  rw [← Icc_union_Icc_eq_Icc hba hac, ← nhdsLE_sup_nhdsGE]
  exact ⟨union_mem_sup hb_nhds hc_nhds, union_subset hbs hcs⟩
```

-- snippet 98
```lean
-- Mathlib.Topology.Order.AtTopBotIxx.comap_coe_nhdsGT_eq_atBot_iff (L73-L79)
theorem comap_coe_nhdsGT_eq_atBot_iff :
    comap ((↑) : s → X) (𝓝[>] b) = atBot ↔
      s ⊆ Ioi b ∧ (s.Nonempty → ∀ a > b, (s ∩ Ioo b a).Nonempty) := by
refine comap_coe_nhdsLT_eq_atTop_iff (s := OrderDual.ofDual ⁻¹' s) (b := OrderDual.toDual b)
    |>.trans ?_
  simp [← preimage_inter, ofDual.surjective]
```

-- snippet 99
```lean
-- Mathlib.Topology.Order.Basic.IsOpen (L490-L502)
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⟩
```

-- snippet 100
```lean
-- Mathlib.Topology.Order.Basic.tendsto_of_tendsto_of_tendsto_of_le_of_le' (L219-L227)
theorem tendsto_of_tendsto_of_tendsto_of_le_of_le' [OrderTopology α] {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

alias Filter.Tendsto.squeeze' := tendsto_of_tendsto_of_tendsto_of_le_of_le'

/-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities
hold everywhere. -/
```

-- snippet 101
```lean
-- Mathlib.Topology.Order.Basic.tendsto_nhds_bot_mono' (L419-L429)
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)

section LinearOrder

variable [TopologicalSpace α] [LinearOrder α]

section OrderTopology
variable [OrderTopology α]
```

-- snippet 102
```lean
-- Mathlib.Topology.Order.Basic.isTopologicalBasis_biInter_Ioi_Iio_of_generateFrom (L183-L218)
lemma isTopologicalBasis_biInter_Ioi_Iio_of_generateFrom (c : Set α)
    (h : ts = generateFrom { s | ∃ a ∈ c, s = Ioi a ∨ s = Iio a }) :
    IsTopologicalBasis {s | ∃ (f g : Set α), f ⊆ c ∧ g ⊆ c ∧ f.Finite ∧ g.Finite
      ∧ s = (⋂ a ∈ f, Ioi a) ∩ (⋂ a ∈ g, Iio a)} := by
refine IsTopologicalBasis.of_isOpen_of_subset ?_ (isTopologicalBasis_of_subbasis h) ?_
  · rintro u ⟨f, g, hfc, hgc, hf_fin, hg_fin, rfl⟩
    apply IsOpen.inter
    · apply hf_fin.isOpen_biInter (fun i hi ↦ ?_)
      rw [h]
      exact isOpen_generateFrom_of_mem ⟨i, hfc hi, Or.inl rfl⟩
    · apply hg_fin.isOpen_biInter (fun i hi ↦ ?_)
      rw [h]
      exact isOpen_generateFrom_of_mem ⟨i, hgc hi, Or.inr rfl⟩
  simp only [exists_and_left, image_subset_iff, preimage_setOf_eq, setOf_subset_setOf, and_imp]
  intro k k_fin hk
  let kl := {s ∈ k | ∃ a ∈ c, s = Ioi a}
  let kr := {s ∈ k | ∃ a ∈ c, s = Iio a}
  have k_eq : k = kl ∪ kr := by
    -- this `have` can be removed, but makes `grind` slower
    have : ∀ s ∈ k, ∃ a ∈ c, s = Ioi a ∨ s = Iio a := hk
    ext
    grind
  have : Finite kl := k_fin.subset (by simp [k_eq])
  have : Finite kr := k_fin.subset (by simp [k_eq])
  have Al : ∀ s : kl, ∃ a ∈ c, s = Ioi a := fun s ↦ s.2.2
  choose al alc hal using Al
  have Ar : ∀ s : kr, ∃ a ∈ c, s = Iio a := fun s ↦ s.2.2
  choose ar arc har using Ar
  refine ⟨range al, by simp [range_subset_iff, alc], range ar,
    by simp [range_subset_iff, arc], finite_range _, finite_range _, ?_⟩
  rw [k_eq, sInter_eq_biInter, biInter_union, biInter_range, biInter_range, biInter_eq_iInter,
    biInter_eq_iInter]
  simp [hal, har]

/-- **Squeeze theorem** (also known as **sandwich theorem**). This version assumes that inequalities
hold eventually for the filter. -/
```

-- snippet 103
```lean
-- Mathlib.Topology.Order.Basic.tendsto_order_unbounded (L240-L247)
theorem tendsto_order_unbounded [OrderTopology α] {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

end Preorder
```

-- snippet 104
```lean
-- Mathlib.Topology.Order.Basic.nhdsLE_basis_of_exists_lt (L367-L371)
theorem nhdsLE_basis_of_exists_lt [TopologicalSpace α] [LinearOrder α] [OrderTopology α] {a : α}
    (ha : ∃ l, l < a) : (𝓝[≤] a).HasBasis (fun l => l < a) fun l => Ioc l a := by
convert nhdsGE_basis_of_exists_gt (α := αᵒᵈ) ha using 2
  exact Ico_toDual.symm
```

-- snippet 105
```lean
-- Mathlib.Topology.Order.Basic.induced_orderTopology (L301-L320)
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⟩

/-- 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. -/
```
[/INST]

mistral-common:Tekken v15 (Mistral chat template, [INST]/[SYSTEM_PROMPT])