Lean library · module TopologyByExample.Spaces.ButterflySpace

The butterfly space

Source file

In this file we define TopologyByExample.Butterfly, the butterfly (or bow-tie) space: the closed upper half-plane {(x, y) | 0 ≤ y}, in which a point with y > 0 has its Euclidean neighbourhoods and a point (x, 0) of the x-axis has the neighbourhoods {(x, 0)} ∪ W, where W = Butterfly.wings x ε is the set of points (a, b) with |a - x| < ε and b < ε |a - x|: the two open triangles of a bow-tie centred at (x, 0), each with one side on the x-axis (the side lying in the set, except for the vertex (x, 0), which the bow-tie adds back).

The type is a synonym of {p : ℝ × ℝ // 0 ≤ p.2} (Butterfly.toPlane is the underlying point of the plane), and the topology is TopologicalSpace.mkOfNhds of the filters Butterfly.nhdsFilter.

The topology is finer than the Euclidean one, so the space is submetrizable. Each bow-tie contains the Euclidean closure of a smaller one, so the space is regular. The x-axis carries the Euclidean topology of the line, and its complement is the Euclidean open half-plane, so the space is the union of two continuous images of second countable spaces: it is hereditarily Lindelöf and σ-compact. The open half-plane is dense, so the space is separable and a Baire space; the bow-ties of size 1 / (n + 1) show that it is first countable; and the parabolic arcs t ↦ (x + t (a - x), t ^ 2 b), which enter every bow-tie at (x, 0), show that it is path connected and locally path connected. It is not second countable: a countable base would contain, for uncountably many x, the same set below the bow-tie of size 1 at (x, 0), and such a set cannot contain a bow-tie at a limit point of those x. No point of the x-axis has a compact neighbourhood, because the vertical half-line above any point of the axis is closed.

Main definitions

Main statements

References

  • E. Michael, ℵ₀-spaces, J. Math. Mech. 15 (1966), Example 12.1.
  • R. Engelking, General Topology, Exercise 3.1.I (a variant with curved bow-ties).

Tags

butterfly space, bow-tie space, perfectly normal space, counterexample

This file was written by Claude (Anthropic's AI model) working under the direction of David R. MacIver, who reviews it and is responsible for it.

Imports

definition Butterfly

TopologyByExample.Butterfly

The butterfly space: the closed upper half-plane {(x, y) | 0 ≤ y}, in which a point with y > 0 has its Euclidean neighbourhoods, and a point (x, 0) has the neighbourhoods {(x, 0)} ∪ {(a, b) | |a - x| < ε, b < ε |a - x|}, ε > 0.

def Butterfly : Type
:= {p : ℝ × ℝ // 0 ≤ p.2}

On this site: Space: Butterfly space

Points

definition toPlane

TopologyByExample.Butterfly.toPlane

The point of the plane ℝ × ℝ underlying a point of the butterfly space.

def toPlane (p : Butterfly) : ℝ × ℝ
:= Subtype.val p

theorem toPlane_injective

TopologyByExample.Butterfly.toPlane_injective

Distinct points of the butterfly space lie over distinct points of the plane.

theorem toPlane_injective : Injective toPlane
Proof
:= Subtype.val_injective

theorem snd_nonneg

TopologyByExample.Butterfly.snd_nonneg

Every point of the butterfly space has nonnegative second coordinate.

theorem snd_nonneg (p : Butterfly) : 0 ≤ p.toPlane.2
Proof
:= Subtype.property p

definition ofPlane

TopologyByExample.Butterfly.ofPlane

The point of the butterfly space over (q.1, max q.2 0).

def ofPlane (q : ℝ × ℝ) : Butterfly
:= ⟨(q.1, max q.2 0), le_max_right _ _⟩

theorem toPlane_ofPlane

TopologyByExample.Butterfly.toPlane_ofPlane

ofPlane is a right inverse of toPlane on the closed upper half-plane.

theorem toPlane_ofPlane {q : ℝ × ℝ} (hq : 0 ≤ q.2) : toPlane (ofPlane q) = q
Proof
:= by
  simp [toPlane, ofPlane, max_eq_left hq]

theorem ofPlane_toPlane

TopologyByExample.Butterfly.ofPlane_toPlane

ofPlane is a left inverse of toPlane.

@[simp]
theorem ofPlane_toPlane (p : Butterfly) : ofPlane (toPlane p) = p
Proof
:=
  toPlane_injective (toPlane_ofPlane p.snd_nonneg)

definition axisPt

TopologyByExample.Butterfly.axisPt

The point (x, 0) of the x-axis.

def axisPt (x : ℝ) : Butterfly
:= ofPlane (x, 0)

theorem toPlane_axisPt

TopologyByExample.Butterfly.toPlane_axisPt

The point (x, 0) lies over (x, 0).

@[simp]
theorem toPlane_axisPt (x : ℝ) : toPlane (axisPt x) = (x, 0)
Proof
:= toPlane_ofPlane le_rfl

instance

The butterfly space is nonempty.

instance : Nonempty Butterfly
Proof
:= ⟨axisPt 0⟩

theorem eq_axisPt

TopologyByExample.Butterfly.eq_axisPt

A point on the x-axis is axisPt of its first coordinate.

theorem eq_axisPt {p : Butterfly} (hp : p.toPlane.2 = 0) : p = axisPt p.toPlane.1
Proof
:=
  toPlane_injective (by rw [toPlane_axisPt]; exact Prod.ext rfl hp)

definition wings

TopologyByExample.Butterfly.wings

The open bow-tie of size ε at (x, 0), without its centre: the points (a, b) with |a - x| < ε and b < ε |a - x|.

def wings (x ε : ℝ) : Set Butterfly
:=
  {p | |p.toPlane.1 - x| < ε ∧ p.toPlane.2 < ε * |p.toPlane.1 - x|}

definition planeWings

TopologyByExample.Butterfly.planeWings

The same set as a subset of the plane ℝ × ℝ.

def planeWings (x ε : ℝ) : Set (ℝ × ℝ)
:= {q | |q.1 - x| < ε ∧ q.2 < ε * |q.1 - x|}

theorem wings_eq_preimage

TopologyByExample.Butterfly.wings_eq_preimage

The bow-tie is the preimage of the corresponding set of the plane.

theorem wings_eq_preimage (x ε : ℝ) : wings x ε = toPlane ⁻¹' planeWings x ε
Proof
:= rfl

theorem isOpen_planeWings

TopologyByExample.Butterfly.isOpen_planeWings

The bow-tie in the plane is open.

theorem isOpen_planeWings (x ε : ℝ) : IsOpen (planeWings x ε)
Proof
:=
  (isOpen_lt (continuous_fst.sub continuous_const).abs continuous_const).inter
    (isOpen_lt continuous_snd (continuous_const.mul (continuous_fst.sub continuous_const).abs))

theorem axisPt_notMem_wings

TopologyByExample.Butterfly.axisPt_notMem_wings

The centre (x, 0) is not in the bow-tie at (x, 0).

theorem axisPt_notMem_wings (x ε : ℝ) : axisPt x ∉ wings x ε
Proof
:= by
  simp [wings]

theorem fst_ne_of_mem_wings

TopologyByExample.Butterfly.fst_ne_of_mem_wings

A point of the bow-tie at (x, 0) has first coordinate different from x.

theorem fst_ne_of_mem_wings {x ε : ℝ} {p : Butterfly} (hp : p ∈ wings x ε) :
    0 < |p.toPlane.1 - x|
Proof
:= by
  obtain ⟨h1, h2⟩ := hp
  have := p.snd_nonneg
  have hε : 0 < ε := (abs_nonneg _).trans_lt h1
  by_contra! h
  nlinarith [abs_nonneg (p.toPlane.1 - x)]

theorem wings_mono

TopologyByExample.Butterfly.wings_mono

Bow-ties at the same point increase with their size.

theorem wings_mono {x ε δ : ℝ} (h : ε ≤ δ) : wings x ε ⊆ wings x δ
Proof
:= fun p hp ↦ by
  have := fst_ne_of_mem_wings hp
  obtain ⟨h1, h2⟩ := hp
  exact ⟨h1.trans_le h, h2.trans_le (by nlinarith)⟩

The topology

definition nhdsFilter

TopologyByExample.Butterfly.nhdsFilter

The neighbourhood filter of a point of the butterfly space: the Euclidean neighbourhoods for a point off the x-axis, and the sets containing {p} ∪ wings x ε for some ε > 0 for a point p = (x, 0) of the x-axis.

def nhdsFilter (p : Butterfly) : Filter Butterfly
:=
  if p.toPlane.2 = 0 then ⨅ ε ∈ Ioi (0 : ℝ), 𝓟 (insert p (wings p.toPlane.1 ε))
  else comap toPlane (𝓝 p.toPlane)

theorem hasBasis_nhdsFilter_axis

TopologyByExample.Butterfly.hasBasis_nhdsFilter_axis

The neighbourhood basis at a point of the x-axis.

theorem hasBasis_nhdsFilter_axis {p : Butterfly} (hp : p.toPlane.2 = 0) :
    (nhdsFilter p).HasBasis (fun ε : ℝ ↦ 0 < ε) fun ε ↦ insert p (wings p.toPlane.1 ε)
Proof
:= by
  simp only [nhdsFilter, hp, ↓reduceIte]
  refine hasBasis_biInf_principal ?_ ⟨1, one_pos⟩
  intro r hr s hs
  refine ⟨min r s, lt_min hr hs, ?_, ?_⟩ <;>
    exact insert_subset_insert (wings_mono (by simp))

theorem preimage_mem_nhdsFilter

TopologyByExample.Butterfly.preimage_mem_nhdsFilter

If V is an open set of the plane contained in the open upper half-plane, its preimage is a neighbourhood (in nhdsFilter) of each of its points.

theorem preimage_mem_nhdsFilter {V : Set (ℝ × ℝ)} (hV : IsOpen V) (hVpos : ∀ q ∈ V, 0 < q.2)
    {p : Butterfly} (hp : p.toPlane ∈ V) : toPlane ⁻¹' V ∈ nhdsFilter p
Proof
:= by
  simp only [nhdsFilter, (hVpos _ hp).ne', ↓reduceIte]
  exact preimage_mem_comap (hV.mem_nhds hp)

theorem mem_planeWings_of_mem_planeWings

TopologyByExample.Butterfly.mem_planeWings_of_mem_planeWings

The inequalities behind the openness of bow-ties: if d = |a - x| satisfies 0 < d < ε, then a bow-tie at (a, 0) of size min (ε - d) (min (d / 2) (ε / 2)) lies in the bow-tie of size ε at (x, 0).

theorem mem_planeWings_of_mem_planeWings {x a ε : ℝ} (hd0 : 0 < |a - x|) (hdε : |a - x| < ε)
    {q : ℝ × ℝ} (hq : q ∈ planeWings a (min (ε - |a - x|) (min (|a - x| / 2)
      (ε / 2)))) : q ∈ planeWings x ε
Proof
:= by
  set d := |a - x|
  set δ := min (ε - d) (min (d / 2) (ε / 2))
  have hδ1 : δ ≤ ε - d := min_le_left _ _
  have hδ2 : δ ≤ d / 2 := (min_le_right _ _).trans (min_le_left _ _)
  have hδ3 : δ ≤ ε / 2 := (min_le_right _ _).trans (min_le_right _ _)
  obtain ⟨h1, h2⟩ := hq
  have hδ : 0 < δ := (abs_nonneg _).trans_lt h1
  have htri1 : |q.1 - x| ≤ |q.1 - a| + d := by
    have := abs_sub_le q.1 a x
    linarith
  have htri2 : d ≤ |q.1 - a| + |q.1 - x| := by
    have := abs_sub_le a q.1 x
    rw [abs_sub_comm a q.1] at this
    linarith
  have hε : 0 < ε := hd0.trans hdε
  refine ⟨by linarith, ?_⟩
  have hb : q.2 < δ * δ := h2.trans_le (mul_le_mul_of_nonneg_left h1.le hδ.le)
  have hdd : δ * δ ≤ (ε / 2) * (d / 2) := mul_le_mul hδ3 hδ2 hδ.le (by linarith)
  have hlow : d / 2 ≤ |q.1 - x| := by linarith
  nlinarith

theorem wings_mem_nhdsFilter

TopologyByExample.Butterfly.wings_mem_nhdsFilter

A bow-tie is a neighbourhood (in nhdsFilter) of each of its points.

theorem wings_mem_nhdsFilter {x ε : ℝ} {p : Butterfly} (hp : p ∈ wings x ε) :
    wings x ε ∈ nhdsFilter p
Proof
:= by
  by_cases h : p.toPlane.2 = 0
  · have hd0 := fst_ne_of_mem_wings hp
    have hdε := hp.1
    set d := |p.toPlane.1 - x|
    refine (hasBasis_nhdsFilter_axis h).mem_iff.2
      ⟨min (ε - d) (min (d / 2) (ε / 2)), lt_min (by linarith) (lt_min (by linarith)
        (by linarith)), fun q hq ↦ ?_⟩
    rcases hq with rfl | hq
    · exact hp
    · exact mem_planeWings_of_mem_planeWings hd0 hdε hq
  · simp only [nhdsFilter, h, ↓reduceIte]
    exact preimage_mem_comap ((isOpen_planeWings x ε).mem_nhds hp)

instance instTopologicalSpace

TopologyByExample.Butterfly.instTopologicalSpace

The butterfly space: its topology is given by the neighbourhood filters nhdsFilter.

instance instTopologicalSpace : TopologicalSpace Butterfly
Proof
:= .mkOfNhds nhdsFilter

theorem nhds_eq

TopologyByExample.Butterfly.nhds_eq

The neighbourhood filters of the butterfly space are the filters nhdsFilter.

theorem nhds_eq (p : Butterfly) : 𝓝 p = nhdsFilter p
Proof
:= by
  refine nhds_mkOfNhds _ _ (fun a ↦ ?_) fun a s hs ↦ ?_
  · by_cases ha : a.toPlane.2 = 0
    · exact (hasBasis_nhdsFilter_axis ha).ge_iff.2 fun _ _ ↦ mem_insert _ _
    · simp only [nhdsFilter, ha, ↓reduceIte]
      exact pure_le_iff.2 fun s hs ↦ by
        obtain ⟨t, ht, hts⟩ := mem_comap.1 hs
        exact hts (show a.toPlane ∈ t from mem_of_mem_nhds ht)
  · by_cases ha : a.toPlane.2 = 0
    · obtain ⟨r, hr, hrs⟩ := (hasBasis_nhdsFilter_axis ha).mem_iff.1 hs
      refine mem_of_superset ((hasBasis_nhdsFilter_axis ha).mem_of_mem hr) fun y hy ↦ ?_
      rcases hy with rfl | hy
      · exact hs
      · exact mem_of_superset (wings_mem_nhdsFilter hy) fun z hz ↦ hrs (Or.inr hz)
    · have hpos : 0 < a.toPlane.2 := lt_of_le_of_ne a.snd_nonneg (Ne.symm ha)
      simp only [nhdsFilter, ha, ↓reduceIte] at hs ⊢
      obtain ⟨t, ht, hts⟩ := mem_comap.1 hs
      set V := interior t ∩ {q : ℝ × ℝ | 0 < q.2}
      have hV : IsOpen V := isOpen_interior.inter (isOpen_lt continuous_const continuous_snd)
      have haV : a.toPlane ∈ V := ⟨mem_interior_iff_mem_nhds.2 ht, hpos⟩
      filter_upwards [preimage_mem_comap (hV.mem_nhds haV)] with y hy
      exact mem_of_superset (preimage_mem_nhdsFilter hV (fun q hq ↦ hq.2) hy)
        fun z hz ↦ hts (show z.toPlane ∈ t from interior_subset hz.1)

theorem nhds_of_ne_zero

TopologyByExample.Butterfly.nhds_of_ne_zero

At a point off the x-axis the neighbourhoods are the Euclidean ones.

theorem nhds_of_ne_zero {p : Butterfly} (hp : p.toPlane.2 ≠ 0) :
    𝓝 p = comap toPlane (𝓝 p.toPlane)
Proof
:= by
  simp only [nhds_eq, nhdsFilter, hp, ↓reduceIte]

theorem nhds_of_pos

TopologyByExample.Butterfly.nhds_of_pos

At a point off the x-axis the neighbourhoods are the Euclidean ones.

theorem nhds_of_pos {p : Butterfly} (hp : 0 < p.toPlane.2) :
    𝓝 p = comap toPlane (𝓝 p.toPlane)
Proof
:=
  nhds_of_ne_zero hp.ne'

theorem hasBasis_nhds_axisPt

TopologyByExample.Butterfly.hasBasis_nhds_axisPt

The neighbourhood basis at a point (x, 0) of the x-axis: the bow-ties {(x, 0)} ∪ wings x ε, ε > 0.

theorem hasBasis_nhds_axisPt (x : ℝ) :
    (𝓝 (axisPt x)).HasBasis (fun ε : ℝ ↦ 0 < ε) fun ε ↦ insert (axisPt x) (wings x ε)
Proof
:= by
  rw [nhds_eq]
  simpa using hasBasis_nhdsFilter_axis (p := axisPt x) (by simp)

theorem isOpen_preimage_toPlane

TopologyByExample.Butterfly.isOpen_preimage_toPlane

The preimage of an open set of the plane contained in the open upper half-plane is open.

theorem isOpen_preimage_toPlane {V : Set (ℝ × ℝ)} (hV : IsOpen V) (hVpos : ∀ q ∈ V, 0 < q.2) :
    IsOpen (toPlane ⁻¹' V)
Proof
:=
  isOpen_iff_mem_nhds.2 fun _ hp ↦ (nhds_eq _).symm ▸ preimage_mem_nhdsFilter hV hVpos hp

theorem isOpen_wings

TopologyByExample.Butterfly.isOpen_wings

Every bow-tie (without its centre) is open.

theorem isOpen_wings (x ε : ℝ) : IsOpen (wings x ε)
Proof
:=
  isOpen_iff_mem_nhds.2 fun _ hp ↦ (nhds_eq _).symm ▸ wings_mem_nhdsFilter hp

theorem isOpen_insert_wings

TopologyByExample.Butterfly.isOpen_insert_wings

A bow-tie of positive size together with its centre is open.

theorem isOpen_insert_wings (x : ℝ) {ε : ℝ} (hε : 0 < ε) :
    IsOpen (insert (axisPt x) (wings x ε))
Proof
:= by
  refine isOpen_iff_mem_nhds.2 fun p hp ↦ ?_
  rcases hp with rfl | hp
  · exact (hasBasis_nhds_axisPt x).mem_of_mem hε
  · exact mem_of_superset ((isOpen_wings x ε).mem_nhds hp) (subset_insert _ _)

theorem continuous_toPlane

TopologyByExample.Butterfly.continuous_toPlane

The map to the plane is continuous: the topology of the butterfly space is finer than the Euclidean one.

theorem continuous_toPlane : Continuous toPlane
Proof
:= by
  refine continuous_iff_continuousAt.2 fun p ↦ ?_
  by_cases hp : p.toPlane.2 = 0
  · rw [eq_axisPt hp]
    refine ((hasBasis_nhds_axisPt _).tendsto_iff Metric.nhds_basis_ball).2 fun r hr ↦
      ⟨min r 1, lt_min hr one_pos, fun q hq ↦ ?_⟩
    rcases hq with rfl | ⟨h1, h2⟩
    · exact Metric.mem_ball_self hr
    · have h0 := q.snd_nonneg
      have hm1 : min r 1 ≤ r := min_le_left _ _
      have hm2 : min r 1 ≤ 1 := min_le_right _ _
      rw [Metric.mem_ball, toPlane_axisPt, Prod.dist_eq, Real.dist_eq, Real.dist_eq, sub_zero,
        abs_of_nonneg h0]
      refine max_lt (by linarith) ?_
      have : min r 1 * |q.toPlane.1 - p.toPlane.1| ≤ 1 * |q.toPlane.1 - p.toPlane.1| :=
        mul_le_mul_of_nonneg_right hm2 (abs_nonneg _)
      linarith
  · rw [ContinuousAt, nhds_of_ne_zero hp]
    exact tendsto_comap

On this site: Butterfly space: The topology is finer than the Euclidean topology

instance t2Space

TopologyByExample.Butterfly.t2Space

The butterfly space is Hausdorff, since its topology is finer than the Euclidean one.

instance t2Space : T2Space Butterfly
Proof
:=
  .of_injective_continuous toPlane_injective continuous_toPlane

instance submetrizableSpace

TopologyByExample.Butterfly.submetrizableSpace

The butterfly space is submetrizable: its topology is finer than the topology induced by the injective map to the Euclidean plane, which is metrizable.

instance submetrizableSpace : SubmetrizableSpace Butterfly
Proof
:= by
  refine ⟨⟨TopologicalSpace.induced toPlane inferInstance,
    continuous_iff_le_induced.1 continuous_toPlane, ?_⟩⟩
  exact @IsEmbedding.metrizableSpace Butterfly (ℝ × ℝ) (TopologicalSpace.induced toPlane
    inferInstance) _ _ toPlane (@IsEmbedding.mk Butterfly (ℝ × ℝ) (TopologicalSpace.induced toPlane
      inferInstance) _ toPlane (@IsInducing.induced Butterfly (ℝ × ℝ) _ toPlane) toPlane_injective)

On this site: The butterfly space is submetrizable

theorem continuousAt_ofPlane

TopologyByExample.Butterfly.continuousAt_ofPlane

ofPlane is continuous at every point of the open upper half-plane.

theorem continuousAt_ofPlane {q : ℝ × ℝ} (hq : 0 < q.2) : ContinuousAt ofPlane q
Proof
:= by
  have h : (ofPlane q).toPlane.2 ≠ 0 := by rw [toPlane_ofPlane hq.le]; exact hq.ne'
  rw [ContinuousAt, nhds_of_ne_zero h, tendsto_comap_iff, toPlane_ofPlane hq.le]
  have hc : Continuous fun q : ℝ × ℝ ↦ (q.1, max q.2 0) := by fun_prop
  simpa [Function.comp_def, toPlane, ofPlane, max_eq_left hq.le] using hc.tendsto q

theorem continuousOn_ofPlane

TopologyByExample.Butterfly.continuousOn_ofPlane

ofPlane is continuous on the open upper half-plane.

theorem continuousOn_ofPlane {V : Set (ℝ × ℝ)} (hV : ∀ q ∈ V, 0 < q.2) : ContinuousOn ofPlane V
Proof
:=
  fun q hq ↦ (continuousAt_ofPlane (hV q hq)).continuousWithinAt

theorem continuous_axisPt

TopologyByExample.Butterfly.continuous_axisPt

The x-axis carries the Euclidean topology: the map x ↦ (x, 0) is continuous, since a bow-tie at (x, 0) contains the points (a, 0) with |a - x| < ε.

theorem continuous_axisPt : Continuous axisPt
Proof
:= by
  refine continuous_iff_continuousAt.2 fun x ↦ ?_
  refine ((hasBasis_nhds_axisPt x).tendsto_right_iff).2 fun ε hε ↦ ?_
  filter_upwards [Metric.ball_mem_nhds x hε] with a ha
  rcases eq_or_ne a x with rfl | hax
  · exact mem_insert _ _
  · refine Or.inr ⟨?_, ?_⟩
    · simpa [Real.dist_eq] using ha
    · simpa using mul_pos hε (abs_pos.2 (sub_ne_zero.2 hax))

The open upper half-plane

definition ofUpper

TopologyByExample.Butterfly.ofUpper

The inclusion of the open upper half-plane {q : ℝ × ℝ | 0 < q.2}, with its Euclidean topology, into the butterfly space.

def ofUpper (q : {q : ℝ × ℝ // 0 < q.2}) : Butterfly
:= ofPlane q.val

theorem toPlane_ofUpper

TopologyByExample.Butterfly.toPlane_ofUpper

The inclusion of the open upper half-plane lies over the identity.

@[simp]
theorem toPlane_ofUpper (q : {q : ℝ × ℝ // 0 < q.2}) : toPlane (ofUpper q) = q.val
Proof
:=
  toPlane_ofPlane q.property.le

theorem continuous_ofUpper

TopologyByExample.Butterfly.continuous_ofUpper

The inclusion of the open upper half-plane is continuous.

theorem continuous_ofUpper : Continuous ofUpper
Proof
:=
  continuous_iff_continuousAt.2 fun q ↦
    (continuousAt_ofPlane q.property).comp continuous_subtypeVal.continuousAt

theorem range_axisPt_union_range_ofUpper

TopologyByExample.Butterfly.range_axisPt_union_range_ofUpper

Every point is on the x-axis or in the open upper half-plane.

theorem range_axisPt_union_range_ofUpper : range axisPt ∪ range ofUpper = univ
Proof
:= by
  refine eq_univ_of_forall fun p ↦ ?_
  by_cases hp : p.toPlane.2 = 0
  · exact Or.inl ⟨_, (eq_axisPt hp).symm⟩
  · exact Or.inr ⟨⟨p.toPlane, lt_of_le_of_ne p.snd_nonneg (Ne.symm hp)⟩, by simp [ofUpper]⟩

theorem ofPlane_mem_wings

TopologyByExample.Butterfly.ofPlane_mem_wings

The point (x + ε / 2, ε ^ 2 / 4) of the open upper half-plane lies in the bow-tie of size ε at (x, 0).

theorem ofPlane_mem_wings (x : ℝ) {ε : ℝ} (hε : 0 < ε) :
    ofPlane (x + ε / 2, ε ^ 2 / 4) ∈ wings x ε
Proof
:= by
  have h0 : (0 : ℝ) ≤ (x + ε / 2, ε ^ 2 / 4).2 := by positivity
  simp only [wings, mem_ofPred_eq, toPlane_ofPlane h0, add_sub_cancel_left,
    abs_of_pos (half_pos hε)]
  constructor <;> nlinarith

theorem denseRange_ofUpper

TopologyByExample.Butterfly.denseRange_ofUpper

The open upper half-plane is dense.

theorem denseRange_ofUpper : DenseRange ofUpper
Proof
:= by
  refine fun p ↦ ?_
  by_cases hp : p.toPlane.2 = 0
  · obtain ⟨x, rfl⟩ : ∃ x, p = axisPt x := ⟨_, eq_axisPt hp⟩
    refine (mem_closure_iff_nhds_basis' (hasBasis_nhds_axisPt x)).2 fun ε hε ↦ ?_
    have hpos : (0 : ℝ) < (x + ε / 2, ε ^ 2 / 4).2 := by positivity
    exact ⟨_, Or.inr (ofPlane_mem_wings x hε), ⟨⟨_, hpos⟩, rfl⟩⟩
  · exact subset_closure ⟨⟨p.toPlane, lt_of_le_of_ne p.snd_nonneg (Ne.symm hp)⟩, by
      simp [ofUpper]⟩

theorem isOpenEmbedding_ofUpper

TopologyByExample.Butterfly.isOpenEmbedding_ofUpper

The open upper half-plane is an open Euclidean subspace: the inclusion of the open upper half-plane, with its Euclidean topology, is an open embedding.

theorem isOpenEmbedding_ofUpper : IsOpenEmbedding ofUpper
Proof
:= by
  refine .of_continuous_injective_isOpenMap continuous_ofUpper ?_ ?_
  · intro a b h
    exact Subtype.ext (by simpa using congrArg toPlane h)
  · intro U hU
    obtain ⟨V, hV, rfl⟩ := isOpen_induced_iff.1 hU
    convert isOpen_preimage_toPlane (hV.inter (isOpen_lt continuous_const continuous_snd))
      fun q hq ↦ hq.2 using 1
    ext p
    constructor
    · rintro ⟨q, hq, rfl⟩
      exact ⟨by simpa using hq, by simp⟩
    · rintro ⟨h1, h2⟩
      exact ⟨⟨p.toPlane, h2⟩, h1, by simp [ofUpper]⟩

On this site: Butterfly space: The open half-plane is an open Euclidean subspace

theorem isClosedEmbedding_axisPt

TopologyByExample.Butterfly.isClosedEmbedding_axisPt

The x-axis is a closed copy of the real line: the map x ↦ (x, 0) is a closed embedding, with the first coordinate as a continuous left inverse.

theorem isClosedEmbedding_axisPt : IsClosedEmbedding axisPt
Proof
:=
  Function.LeftInverse.isClosedEmbedding (f := fun p : Butterfly ↦ p.toPlane.1)
    (fun x ↦ by simp) (continuous_fst.comp continuous_toPlane) continuous_axisPt

On this site: Butterfly space: The axis is a closed copy of the real line

Countability properties

instance separableSpace

TopologyByExample.Butterfly.separableSpace

The butterfly space is separable: the open upper half-plane is dense, and separable.

instance separableSpace : SeparableSpace Butterfly
Proof
:=
  denseRange_ofUpper.separableSpace continuous_ofUpper

On this site: The butterfly space is separable

instance firstCountableTopology

TopologyByExample.Butterfly.firstCountableTopology

The butterfly space is first countable: the bow-ties of size 1 / (n + 1) form a neighbourhood basis at a point of the x-axis.

instance firstCountableTopology : FirstCountableTopology Butterfly
Proof
:= by
  refine ⟨fun p ↦ ?_⟩
  by_cases hp : p.toPlane.2 = 0
  · obtain ⟨x, rfl⟩ : ∃ x, p = axisPt x := ⟨_, eq_axisPt hp⟩
    refine ((hasBasis_nhds_axisPt x).to_hasBasis (p' := fun _ : ℕ ↦ True)
      (s' := fun n ↦ insert (axisPt x) (wings x (1 / (n + 1)))) ?_ ?_).isCountablyGenerated
    · intro r hr
      obtain ⟨n, hn⟩ := exists_nat_one_div_lt hr
      exact ⟨n, trivial, insert_subset_insert (wings_mono hn.le)⟩
    · exact fun n _ ↦ ⟨1 / (n + 1), Nat.one_div_pos_of_nat, subset_rfl⟩
  · rw [nhds_of_ne_zero hp]
    infer_instance

On this site: The butterfly space is first countable

instance hereditarilyLindelofSpace

TopologyByExample.Butterfly.hereditarilyLindelofSpace

The butterfly space is hereditarily Lindelöf: every subset is the union of its part on the x-axis and its part in the open upper half-plane, each the image under a continuous map of a subset of a second countable space, hence Lindelöf.

instance hereditarilyLindelofSpace : HereditarilyLindelofSpace Butterfly
Proof
:= by
  refine ⟨fun s _ ↦ ?_⟩
  have h1 : IsLindelof (axisPt '' (axisPt ⁻¹' s)) :=
    (HereditarilyLindelofSpace.isLindelof _).image continuous_axisPt
  have h2 : IsLindelof (ofUpper '' (ofUpper ⁻¹' s)) :=
    (HereditarilyLindelofSpace.isLindelof _).image continuous_ofUpper
  convert h1.union h2 using 1
  rw [image_preimage_eq_inter_range, image_preimage_eq_inter_range, ← inter_union_distrib_left,
    range_axisPt_union_range_ofUpper, inter_univ]

On this site: The butterfly space is hereditarily Lindelöf

instance sigmaCompactSpace

TopologyByExample.Butterfly.sigmaCompactSpace

The butterfly space is σ-compact: it is the union of the x-axis, a continuous image of the real line, and the open upper half-plane, a locally compact second countable space.

instance sigmaCompactSpace : SigmaCompactSpace Butterfly
Proof
:= by
  have : LocallyCompactSpace {q : ℝ × ℝ // 0 < q.2} :=
    (isOpen_lt continuous_const continuous_snd : IsOpen {q : ℝ × ℝ | 0 < q.2}).locallyCompactSpace
  have h1 := isSigmaCompact_range continuous_axisPt
  have h2 := isSigmaCompact_range continuous_ofUpper
  rw [← isSigmaCompact_univ_iff, ← range_axisPt_union_range_ofUpper, union_eq_iUnion]
  exact isSigmaCompact_iUnion _ fun b ↦ by cases b <;> assumption

On this site: The butterfly space is σ-compact

Regularity

theorem closedBowTie_subset

TopologyByExample.Butterfly.closedBowTie_subset

The bow-tie of size ε / 2 at (x, 0), with its centre, lies in the closed set of points (a, b) with |a - x| ≤ ε / 2 and b ≤ (ε / 2) |a - x|, which in turn lies in the bow-tie of size ε with its centre.

theorem closedBowTie_subset (x : ℝ) {ε : ℝ} (hε : 0 < ε) :
    toPlane ⁻¹' {q : ℝ × ℝ | |q.1 - x| ≤ ε / 2 ∧ q.2 ≤ ε / 2 * |q.1 - x|} ⊆
      insert (axisPt x) (wings x ε)
Proof
:= by
  intro p ⟨h1, h2⟩
  have h0 := p.snd_nonneg
  rcases (abs_nonneg (p.toPlane.1 - x)).eq_or_lt with h | h
  · left
    have hx : p.toPlane.1 = x := sub_eq_zero.1 (abs_eq_zero.1 h.symm)
    rw [← h, mul_zero] at h2
    exact toPlane_injective (Prod.ext (by simp [hx]) (by simp; linarith))
  · exact Or.inr ⟨by linarith, by nlinarith⟩

instance regularSpace

TopologyByExample.Butterfly.regularSpace

The butterfly space is regular: every bow-tie contains a smaller bow-tie together with its Euclidean closure, and at a point off the x-axis the Euclidean closed balls are closed neighbourhoods.

instance regularSpace : RegularSpace Butterfly
Proof
:= by
  refine .of_exists_mem_nhds_isClosed_subset fun p s hs ↦ ?_
  by_cases hp : p.toPlane.2 = 0
  · obtain ⟨x, rfl⟩ : ∃ x, p = axisPt x := ⟨_, eq_axisPt hp⟩
    obtain ⟨ε, hε, hεs⟩ := (hasBasis_nhds_axisPt x).mem_iff.1 hs
    refine ⟨_, ?_, IsClosed.preimage continuous_toPlane ?_,
      (closedBowTie_subset x hε).trans hεs⟩
    · refine mem_of_superset ((hasBasis_nhds_axisPt x).mem_of_mem (half_pos hε)) ?_
      rintro q (rfl | ⟨h1, h2⟩)
      · simpa using (half_pos hε).le
      · exact ⟨h1.le, h2.le⟩
    · exact (isClosed_le (continuous_fst.sub continuous_const).abs continuous_const).inter
        (isClosed_le continuous_snd
          (continuous_const.mul (continuous_fst.sub continuous_const).abs))
  · have hs' : s ∈ comap toPlane (𝓝 p.toPlane) := nhds_of_ne_zero hp ▸ hs
    obtain ⟨t, ht, hts⟩ := mem_comap.1 hs'
    obtain ⟨r, hr, hrt⟩ := Metric.nhds_basis_closedBall.mem_iff.1 ht
    refine ⟨toPlane ⁻¹' Metric.closedBall p.toPlane r, ?_,
      Metric.isClosed_closedBall.preimage continuous_toPlane, fun q hq ↦ hts (hrt hq)⟩
    rw [nhds_of_ne_zero hp]
    exact preimage_mem_comap (Metric.closedBall_mem_nhds _ hr)

On this site: The butterfly space is regular

Path connectedness

definition arc

TopologyByExample.Butterfly.arc

The parabolic arc from (x, 0) towards (a, b): t ↦ (x + t (a - x), t ^ 2 b). For 0 ≤ t ≤ 1 and b > 0 it runs below the segment from (x, 0) to (a, b) and is tangent to the x-axis at (x, 0), so it enters every bow-tie there.

def arc (x a b t : ℝ) : Butterfly
:= ofPlane (x + t * (a - x), t ^ 2 * b)

theorem arc_zero

TopologyByExample.Butterfly.arc_zero

The arc starts at (x, 0).

theorem arc_zero (x a b : ℝ) : arc x a b 0 = axisPt x
Proof
:= by simp [arc, axisPt]

theorem arc_one

TopologyByExample.Butterfly.arc_one

The arc ends at (a, b).

theorem arc_one (x : ℝ) (p : Butterfly) : arc x p.toPlane.1 p.toPlane.2 1 = p
Proof
:= by
  simp [arc]

theorem continuous_arc

TopologyByExample.Butterfly.continuous_arc

The arc is continuous when it lies on the x-axis (b = 0) or leaves (x, 0) obliquely (a ≠ x).

theorem continuous_arc {x a b : ℝ} (hb : 0 ≤ b) (hab : b = 0 ∨ a ≠ x) :
    Continuous (arc x a b)
Proof
:= by
  rcases hab with rfl | hax
  · have : arc x a 0 = fun t ↦ axisPt (x + t * (a - x)) := by
      ext t
      simp [arc, axisPt]
    rw [this]
    exact continuous_axisPt.comp (by fun_prop)
  rcases hb.eq_or_lt with rfl | hb
  · have : arc x a 0 = fun t ↦ axisPt (x + t * (a - x)) := by
      ext t
      simp [arc, axisPt]
    rw [this]
    exact continuous_axisPt.comp (by fun_prop)
  refine continuous_iff_continuousAt.2 fun t ↦ ?_
  rcases eq_or_ne t 0 with rfl | ht
  · rw [ContinuousAt, arc_zero]
    refine ((hasBasis_nhds_axisPt x).tendsto_right_iff).2 fun ε hε ↦ ?_
    set d := |a - x|
    have hd : 0 < d := abs_pos.2 (sub_ne_zero.2 hax)
    filter_upwards [Metric.ball_mem_nhds (0 : ℝ) (lt_min (div_pos hε hd)
      (div_pos (mul_pos hε hd) hb))] with s hs
    rw [Metric.mem_ball, Real.dist_eq, sub_zero, lt_min_iff, lt_div_iff₀ hd,
      lt_div_iff₀ hb] at hs
    rcases eq_or_ne s 0 with rfl | hs0
    · exact Or.inl (arc_zero x a b)
    · right
      have hsp : 0 < |s| := abs_pos.2 hs0
      have h0 : (0 : ℝ) ≤ (x + s * (a - x), s ^ 2 * b).2 := by positivity
      simp only [arc, wings, mem_ofPred_eq, toPlane_ofPlane h0, add_sub_cancel_left, abs_mul]
      refine ⟨hs.1, ?_⟩
      rw [← sq_abs s]
      nlinarith
  · have hpos : (0 : ℝ) < (x + t * (a - x), t ^ 2 * b).2 := by
      have := pow_pos (abs_pos.2 ht) 2
      rw [sq_abs] at this
      exact mul_pos this hb
    exact ContinuousAt.comp (g := ofPlane) (f := fun s : ℝ ↦ (x + s * (a - x), s ^ 2 * b))
      (continuousAt_ofPlane hpos) (by fun_prop)

theorem arc_mem

TopologyByExample.Butterfly.arc_mem

The arc from the centre of a bow-tie to a point of it stays in the bow-tie for 0 ≤ t ≤ 1.

theorem arc_mem {x ε : ℝ} {p : Butterfly} (hp : p ∈ insert (axisPt x) (wings x ε)) {t : ℝ}
    (ht0 : 0 ≤ t) (ht1 : t ≤ 1) :
    arc x p.toPlane.1 p.toPlane.2 t ∈ insert (axisPt x) (wings x ε)
Proof
:= by
  rcases hp with rfl | hp
  · left
    rw [toPlane_axisPt]
    simp [arc, axisPt]
  rcases ht0.eq_or_lt with rfl | ht
  · exact Or.inl (arc_zero _ _ _)
  right
  have hd := fst_ne_of_mem_wings hp
  obtain ⟨h1, h2⟩ := hp
  have hb := p.snd_nonneg
  have h0 : (0 : ℝ) ≤ (x + t * (p.toPlane.1 - x), t ^ 2 * p.toPlane.2).2 := by positivity
  simp only [arc, wings, mem_ofPred_eq, toPlane_ofPlane h0, add_sub_cancel_left, abs_mul,
    abs_of_pos ht]
  constructor
  · nlinarith
  · have : t * p.toPlane.2 ≤ p.toPlane.2 := by nlinarith
    nlinarith

theorem isPathConnected_insert_wings

TopologyByExample.Butterfly.isPathConnected_insert_wings

A bow-tie of positive size together with its centre is path connected: the parabolic arcs join its centre to each of its points.

theorem isPathConnected_insert_wings (x ε : ℝ) :
    IsPathConnected (insert (axisPt x) (wings x ε))
Proof
:= by
  refine ⟨axisPt x, mem_insert _ _, fun {p} hp ↦ ?_⟩
  have hab : p.toPlane.2 = 0 ∨ p.toPlane.1 ≠ x := by
    rcases hp with rfl | hp
    · simp
    · exact Or.inr fun h ↦ (fst_ne_of_mem_wings hp).ne' (by simp [h])
  let γ : Path (axisPt x) p :=
    { toFun := fun t ↦ arc x p.toPlane.1 p.toPlane.2 t
      continuous_toFun := (continuous_arc p.snd_nonneg hab).comp continuous_subtypeVal
      source' := arc_zero _ _ _
      target' := arc_one x p }
  exact ⟨γ, fun t ↦ arc_mem hp (unitInterval.nonneg t) (unitInterval.le_one t)⟩

On this site: Butterfly space: The bow-ties are path connected

theorem isPathConnected_upper

TopologyByExample.Butterfly.isPathConnected_upper

The open upper half-plane is path connected.

theorem isPathConnected_upper : IsPathConnected (ofPlane '' {q : ℝ × ℝ | 0 < q.2})
Proof
:= by
  have hconv : Convex ℝ {q : ℝ × ℝ | 0 < q.2} := by
    intro a ha b hb s t hs ht hst
    simp only [mem_ofPred_eq, Prod.snd_add, Prod.smul_snd, smul_eq_mul] at ha hb ⊢
    rcases hs.eq_or_lt with rfl | hs
    · simp only [zero_add] at hst
      simp [hst, hb]
    · positivity
  exact (hconv.isPathConnected ⟨(0, 1), by simp⟩).image' (continuousOn_ofPlane fun _ h ↦ h)

instance pathPreconnectedSpace

TopologyByExample.Butterfly.pathPreconnectedSpace

The butterfly space is path connected.

instance pathPreconnectedSpace : PathPreconnectedSpace Butterfly
Proof
:= by
  have key : ∀ p : Butterfly, Joined p (ofPlane (0, 1)) := by
    have h01 : ofPlane (0, 1) ∈ ofPlane '' {q : ℝ × ℝ | 0 < q.2} := ⟨(0, 1), by simp, rfl⟩
    have hup : ∀ q : ℝ × ℝ, 0 < q.2 → Joined (ofPlane q) (ofPlane (0, 1)) := fun q hq ↦
      (isPathConnected_upper.joinedIn _ ⟨q, hq, rfl⟩ _ h01).joined
    intro p
    by_cases hp : p.toPlane.2 = 0
    · obtain ⟨x, rfl⟩ : ∃ x, p = axisPt x := ⟨_, eq_axisPt hp⟩
      have hmem : ofPlane (x + 1, 1) ∈ wings x 2 := by
        simp only [wings, mem_ofPred_eq, toPlane_ofPlane (show (0 : ℝ) ≤ (x + 1, 1).2 by simp),
          add_sub_cancel_left, abs_one]
        norm_num
      exact ((isPathConnected_insert_wings x 2).joinedIn _ (mem_insert _ _) _
        (mem_insert_of_mem _ hmem)).joined.trans (hup (x + 1, 1) one_pos)
    · rw [← ofPlane_toPlane p]
      exact hup _ (lt_of_le_of_ne p.snd_nonneg (Ne.symm hp))
  exact ⟨fun p q ↦ (key p).trans (key q).symm⟩

On this site: The butterfly space is path connected

instance locallyPathConnectedSpace

TopologyByExample.Butterfly.locallyPathConnectedSpace

The butterfly space is locally path connected: the bow-ties with their centres at a point of the x-axis, and small Euclidean balls elsewhere, are path connected.

instance locallyPathConnectedSpace : LocallyPathConnectedSpace Butterfly
Proof
:= by
  refine ⟨fun p ↦ ⟨fun s ↦ ⟨fun hs ↦ ?_, fun ⟨t, ⟨ht, _⟩, hts⟩ ↦ mem_of_superset ht hts⟩⟩⟩
  by_cases hp : p.toPlane.2 = 0
  · obtain ⟨x, rfl⟩ : ∃ x, p = axisPt x := ⟨_, eq_axisPt hp⟩
    obtain ⟨r, hr, hrs⟩ := (hasBasis_nhds_axisPt x).mem_iff.1 hs
    exact ⟨_, ⟨(hasBasis_nhds_axisPt x).mem_of_mem hr, isPathConnected_insert_wings x r⟩, hrs⟩
  · have hpos : 0 < p.toPlane.2 := lt_of_le_of_ne p.snd_nonneg (Ne.symm hp)
    have hs' : s ∈ comap toPlane (𝓝 p.toPlane) := nhds_of_ne_zero hp ▸ hs
    obtain ⟨t, ht, hts⟩ := mem_comap.1 hs'
    obtain ⟨ε, hε, hεt⟩ := Metric.mem_nhds_iff.1 ht
    set δ := min ε p.toPlane.2
    have hδ : 0 < δ := lt_min hε hpos
    have hBpos : ∀ q ∈ Metric.ball p.toPlane δ, 0 < q.2 := fun q hq ↦ by
      rw [Metric.mem_ball, Prod.dist_eq, Real.dist_eq, Real.dist_eq] at hq
      have := abs_sub_lt_iff.1 ((le_max_right _ _).trans_lt hq)
      linarith [min_le_right ε p.toPlane.2]
    refine ⟨ofPlane '' Metric.ball p.toPlane δ, ⟨?_, ?_⟩, ?_⟩
    · rw [nhds_of_ne_zero hp]
      exact mem_of_superset (preimage_mem_comap (Metric.ball_mem_nhds _ hδ))
        fun z hz ↦ ⟨z.toPlane, hz, ofPlane_toPlane z⟩
    · exact ((convex_ball _ _).isPathConnected ⟨_, Metric.mem_ball_self hδ⟩).image'
        (continuousOn_ofPlane hBpos)
    · rintro _ ⟨q, hq, rfl⟩
      refine hts (show toPlane (ofPlane q) ∈ t from ?_)
      rw [toPlane_ofPlane (hBpos q hq).le]
      exact hεt (Metric.ball_subset_ball (min_le_left _ _) hq)

The Baire property

theorem baireSpace_closedHalfPlane

TopologyByExample.Butterfly.baireSpace_closedHalfPlane

The closed upper half-plane, with its Euclidean topology, is a Baire space: it is a closed subset of the complete metric space ℝ × ℝ.

theorem baireSpace_closedHalfPlane : BaireSpace {q : ℝ × ℝ // 0 ≤ q.2}
Proof
:= by
  have : CompleteSpace {q : ℝ × ℝ // 0 ≤ q.2} :=
    (isClosed_le continuous_const continuous_snd : IsClosed {q : ℝ × ℝ | 0 ≤ q.2}).completeSpace_coe
  infer_instance

theorem baireSpace

TopologyByExample.Butterfly.baireSpace

The butterfly space is a Baire space: the identity onto the closed upper half-plane with its Euclidean topology is continuous, and every nonempty open set contains a nonempty Euclidean open set.

theorem baireSpace : BaireSpace Butterfly
Proof
:= by
  have := baireSpace_closedHalfPlane
  refine baireSpace_of_continuous_of_surjective
    (f := fun p : Butterfly ↦ (⟨p.toPlane, p.snd_nonneg⟩ : {q : ℝ × ℝ // 0 ≤ q.2}))
    (continuous_toPlane.subtype_mk _) (fun q ↦ ⟨show Butterfly from q, rfl⟩) fun U hU hne ↦ ?_
  obtain ⟨v, hvU, hv⟩ : ∃ v ∈ U, 0 < v.toPlane.2 := by
    obtain ⟨u, hu⟩ := hne
    by_cases h : u.toPlane.2 = 0
    · obtain ⟨x, rfl⟩ : ∃ x, u = axisPt x := ⟨_, eq_axisPt h⟩
      obtain ⟨r, hr, hrU⟩ := (hasBasis_nhds_axisPt x).mem_iff.1 (hU.mem_nhds hu)
      refine ⟨_, hrU (Or.inr (ofPlane_mem_wings x hr)), ?_⟩
      rw [toPlane_ofPlane (show (0 : ℝ) ≤ (x + r / 2, r ^ 2 / 4).2 by positivity)]
      positivity
    · exact ⟨u, hu, lt_of_le_of_ne u.snd_nonneg (Ne.symm h)⟩
  have hU' : U ∈ comap toPlane (𝓝 v.toPlane) := nhds_of_pos hv ▸ hU.mem_nhds hvU
  obtain ⟨t, ht, hts⟩ := mem_comap.1 hU'
  refine ⟨Subtype.val ⁻¹' interior t, isOpen_interior.preimage continuous_subtypeVal,
    ⟨⟨v.toPlane, v.snd_nonneg⟩, mem_interior_iff_mem_nhds.2 ht⟩, fun p hp ↦ hts ?_⟩
  exact interior_subset (s := t) hp

On this site: The butterfly space is a Baire space

Negative properties

theorem not_secondCountableTopology

TopologyByExample.Butterfly.not_secondCountableTopology

The butterfly space is not second countable. Choose, for each real x, a member of a countable base containing (x, 0) and contained in the bow-tie of size 1 at (x, 0). Some member B is chosen for uncountably many x, and some such x is a limit from the right of the others. B contains a bow-tie of some size δ at (x, 0); for a chosen y with x < y < x + δ it then contains the points just above (y, 0), which no bow-tie at (y, 0) contains.

theorem not_secondCountableTopology : ¬SecondCountableTopology Butterfly
Proof
:= by
  intro h
  have hB := isBasis_countableBasis Butterfly
  have hBc := countable_countableBasis Butterfly
  have hex : ∀ x : ℝ, ∃ b ∈ countableBasis Butterfly, axisPt x ∈ b ∧ b ⊆ insert (axisPt x)
      (wings x 1) := fun x ↦
    hB.exists_subset_of_mem_open (mem_insert _ _) (isOpen_insert_wings x one_pos)
  choose B hBmem hxB hBsub using hex
  obtain ⟨b, hb⟩ : ∃ b, ¬(B ⁻¹' {b}).Countable := by
    by_contra! hc
    have : (univ : Set ℝ) ⊆ ⋃ b ∈ countableBasis Butterfly, B ⁻¹' {b} := fun x _ ↦
      mem_biUnion (hBmem x) rfl
    exact not_countable_univ ((hBc.biUnion fun b _ ↦ hc b).mono this)
  set S := B ⁻¹' {b}
  obtain ⟨x, hxS, hx⟩ : ∃ x ∈ S, 𝓝[S ∩ Ioi x] x ≠ ⊥ := by
    by_contra! hc
    have hcount : {x ∈ S | 𝓝[S ∩ Ioi x] x = ⊥}.Countable :=
      countable_setOfPred_isolated_right_within
    refine hb (hcount.mono ?_)
    intro y hy
    exact ⟨hy, hc y hy⟩
  have hBx : B x = b := hxS
  obtain ⟨δ, hδ, hδb⟩ := (hasBasis_nhds_axisPt x).mem_iff.1
    ((hB.isOpen (hBmem x)).mem_nhds (hxB x))
  have : (𝓝[S ∩ Ioi x] x).NeBot := ⟨hx⟩
  obtain ⟨y, hy⟩ := Filter.nonempty_of_mem (inter_mem_nhdsWithin (S ∩ Ioi x)
    (Iio_mem_nhds (show x < x + δ by linarith)))
  have hyS : y ∈ S := hy.1.1
  have hxy : x < y := hy.1.2
  replace hy : y < x + δ := hy.2
  have hBy : B y = b := hyS
  have hxy' : 0 < y - x := sub_pos.2 hxy
  have hprod : 0 < δ * (y - x) := mul_pos hδ hxy'
  set t := δ * (y - x) / 2 with ht_def
  have ht : 0 < t := by positivity
  have htlt : t < δ * (y - x) := by linarith
  have h0 : (0 : ℝ) ≤ (y, t).2 := ht.le
  have hmem : ofPlane (y, t) ∈ B y := by
    rw [hBy, ← hBx]
    refine hδb (Or.inr ?_)
    simp only [wings, mem_ofPred_eq, toPlane_ofPlane h0, abs_of_pos hxy']
    exact ⟨by linarith, htlt⟩
  rcases hBsub y hmem with h | ⟨-, h⟩
  · have := congrArg (fun p ↦ p.toPlane.2) h
    simp only [toPlane_ofPlane h0, toPlane_axisPt] at this
    linarith
  · simp only [toPlane_ofPlane h0, sub_self, abs_zero, mul_zero] at h
    linarith

On this site: The butterfly space is not second countable

theorem isClosed_verticalRay

TopologyByExample.Butterfly.isClosed_verticalRay

The vertical half-line {(c, y) | y > 0} is closed: a bow-tie at (c, 0) contains no point directly above (c, 0), a small bow-tie at another point of the x-axis misses the line {(c, y)}, and off the x-axis the topology is Euclidean.

theorem isClosed_verticalRay (c : ℝ) :
    IsClosed {p : Butterfly | p.toPlane.1 = c ∧ 0 < p.toPlane.2}
Proof
:= by
  refine isOpen_compl_iff.1 (isOpen_iff_mem_nhds.2 fun p hp ↦ ?_)
  by_cases h : p.toPlane.2 = 0
  · obtain ⟨x, rfl⟩ : ∃ x, p = axisPt x := ⟨_, eq_axisPt h⟩
    have key : ∀ ε, 0 < ε → (x = c ∨ ε ≤ |c - x|) →
        insert (axisPt x) (wings x ε) ⊆ {p : Butterfly | p.toPlane.1 = c ∧ 0 < p.toPlane.2}ᶜ := by
      rintro ε - hε q (rfl | ⟨h1, h2⟩) ⟨hq1, hq2⟩
      · simp at hq2
      · rw [hq1] at h1 h2
        rcases hε with rfl | hε
        · simp only [sub_self, abs_zero, mul_zero] at h2
          linarith
        · linarith
    rcases eq_or_ne x c with rfl | hxc
    · exact mem_of_superset ((hasBasis_nhds_axisPt x).mem_of_mem one_pos) (key 1 one_pos
        (Or.inl rfl))
    · have hd : 0 < |c - x| := abs_pos.2 (sub_ne_zero.2 (Ne.symm hxc))
      exact mem_of_superset ((hasBasis_nhds_axisPt x).mem_of_mem hd) (key _ hd (Or.inr le_rfl))
  · have hc : p.toPlane.1 ≠ c := fun h1 ↦
      hp ⟨h1, lt_of_le_of_ne p.snd_nonneg (Ne.symm h)⟩
    rw [nhds_of_ne_zero h]
    refine mem_of_superset (preimage_mem_comap
      ((isOpen_ne_fun continuous_fst continuous_const).mem_nhds (show p.toPlane.1 ≠ c from hc)))
      fun q hq ⟨hq1, _⟩ ↦ hq hq1

theorem not_weaklyLocallyCompactSpace

TopologyByExample.Butterfly.not_weaklyLocallyCompactSpace

The butterfly space is not weakly locally compact: no point of the x-axis has a compact neighbourhood. If K were one at (x, 0), containing the bow-tie of size ε, then its intersection with the closed vertical half-line above (x + ε / 2, 0) would be compact, hence its image compact and closed in the Euclidean plane; but that image contains the points (x + ε / 2, t), 0 < t < ε ^ 2 / 2, which converge to (x + ε / 2, 0).

theorem not_weaklyLocallyCompactSpace : ¬WeaklyLocallyCompactSpace Butterfly
Proof
:= by
  intro h
  obtain ⟨K, hK, hKn⟩ := h.exists_compact_mem_nhds (axisPt 0)
  obtain ⟨ε, hε, hεK⟩ := (hasBasis_nhds_axisPt 0).mem_iff.1 hKn
  set c := ε / 2
  set L := {p : Butterfly | p.toPlane.1 = c ∧ 0 < p.toPlane.2}
  have hcl : IsClosed (toPlane '' (K ∩ L)) :=
    ((hK.inter_right (isClosed_verticalRay c)).image continuous_toPlane).isClosed
  have hmem : (c, (0 : ℝ)) ∈ closure (toPlane '' (K ∩ L)) := by
    refine Metric.mem_closure_iff.2 fun r hr ↦ ?_
    set t := min (r / 2) (ε ^ 2 / 4)
    have ht : 0 < t := lt_min (half_pos hr) (by positivity)
    have htr : t ≤ r / 2 := min_le_left _ _
    have htε : t ≤ ε ^ 2 / 4 := min_le_right _ _
    have h0 : (0 : ℝ) ≤ (c, t).2 := ht.le
    refine ⟨(c, t), ⟨ofPlane (c, t), ⟨hεK (Or.inr ?_), ?_⟩, toPlane_ofPlane h0⟩, ?_⟩
    · simp only [wings, mem_ofPred_eq, toPlane_ofPlane h0, sub_zero, c,
        abs_of_pos (half_pos hε)]
      constructor <;> nlinarith
    · change (ofPlane (c, t)).toPlane.1 = c ∧ 0 < (ofPlane (c, t)).toPlane.2
      rw [toPlane_ofPlane h0]
      exact ⟨rfl, ht⟩
    · rw [Prod.dist_eq, Real.dist_eq, Real.dist_eq]
      simp only [sub_self, abs_zero, zero_sub, abs_neg, abs_of_pos ht]
      exact max_lt hr (by linarith)
  rw [hcl.closure_eq] at hmem
  obtain ⟨p, ⟨-, -, hpL⟩, hp⟩ := hmem
  rw [hp] at hpL
  exact lt_irrefl _ hpL

On this site: The butterfly space is not weakly locally compact