Lean library Β· module TopologyByExample.Theorems.ReciprocalMetricExamples

Accumulation and metric incompleteness of the reciprocal sequence

Source file

These statements distinguish the topology of a reciprocal subspace from the completeness of its inherited real metric.

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

Imports

theorem tendsto_reciprocal

TopologyByExample.BookReciprocals.tendsto_reciprocal

The reciprocal sequence converges to zero in the ambient real line.

theorem tendsto_reciprocal : Tendsto reciprocal atTop (𝓝 0)
Proof
:=
  tendsto_one_div_add_atTop_nhds_zero_nat (π•œ := ℝ)

theorem reciprocal_pos

TopologyByExample.BookReciprocals.reciprocal_pos

Every term is strictly positive.

theorem reciprocal_pos (n : β„•) : 0 < reciprocal n
Proof
:= by unfold reciprocal; positivity

theorem zero_not_mem_reciprocal

TopologyByExample.BookReciprocals.zero_not_mem_reciprocal

Zero is not a point of the reciprocal subspace.

theorem zero_not_mem_reciprocal : (0 : ℝ) βˆ‰ reciprocalSet
Proof
:= by
  rintro ⟨n, hn⟩
  exact (ne_of_gt (reciprocal_pos n)) hn

theorem infinite_reciprocals_in_nhds

TopologyByExample.BookReciprocals.infinite_reciprocals_in_nhds

Each neighbourhood of zero contains infinitely many positive reciprocals.

theorem infinite_reciprocals_in_nhds {U : Set ℝ} (hU : U ∈ 𝓝 0) :
    (U ∩ reciprocalSet).Infinite
Proof
:= by
  obtain ⟨N, hN⟩ := eventually_atTop.mp (tendsto_reciprocal hU)
  have hi : Function.Injective (fun n : β„• ↦ reciprocal (n + N)) := by
    intro n m h
    exact Nat.add_right_cancel (isEmbedding_reciprocal.injective h)
  apply (Set.infinite_range_of_injective hi).mono
  rintro _ ⟨n, rfl⟩
  exact ⟨hN _ (by omega), mem_range_self _⟩

theorem accPt_intervalUnion

TopologyByExample.BookReciprocals.accPt_intervalUnion

Zero is an accumulation point of the sequence together with the distant interval.

theorem accPt_intervalUnion : AccPt (0 : ℝ) (π“Ÿ intervalUnion)
Proof
:= by
  apply accPt_iff_nhds.mpr
  intro U hU
  obtain ⟨x, hxU, hx⟩ := (infinite_reciprocals_in_nhds hU).nonempty
  refine ⟨x, ⟨hxU, Or.inl hx⟩, ?_⟩
  rintro rfl
  exact zero_not_mem_reciprocal hx

theorem infinite_intervalUnion_in_nhds

TopologyByExample.BookReciprocals.infinite_intervalUnion_in_nhds

In fact every neighbourhood meets that union in infinitely many points.

theorem infinite_intervalUnion_in_nhds {U : Set ℝ} (hU : U ∈ 𝓝 0) :
    (U ∩ intervalUnion).Infinite
Proof
:=
  (infinite_reciprocals_in_nhds hU).mono (inter_subset_inter_right _ subset_union_left)

theorem countable_intervalUnion_in_some_nhds

TopologyByExample.BookReciprocals.countable_intervalUnion_in_some_nhds

A neighbourhood of zero has only countably many points of the union.

theorem countable_intervalUnion_in_some_nhds :
    βˆƒ U ∈ 𝓝 (0 : ℝ), (U ∩ intervalUnion).Countable
Proof
:= by
  refine ⟨Iio 2, Iio_mem_nhds (by norm_num), (countable_range reciprocal).mono ?_⟩
  rintro x ⟨hx, hxA | hxI⟩
  Β· exact hxA
  Β· exact False.elim (not_lt_of_ge hxI.1 hx)

definition sequence

TopologyByExample.BookReciprocals.sequence

The same sequence, with codomain its positive reciprocal subspace.

def sequence (n : β„•) : reciprocalSet
:= ⟨reciprocal n, mem_range_self n⟩

theorem cauchySeq_sequence

TopologyByExample.BookReciprocals.cauchySeq_sequence

The inherited metric makes this sequence Cauchy.

theorem cauchySeq_sequence : CauchySeq sequence
Proof
:= by
  rw [Metric.cauchySeq_iff]
  have hc := Metric.cauchySeq_iff.mp tendsto_reciprocal.cauchySeq
  simpa only [sequence, Subtype.dist_eq] using hc

theorem not_tendsto_sequence

TopologyByExample.BookReciprocals.not_tendsto_sequence

It converges to no point of the reciprocal subspace.

theorem not_tendsto_sequence (x : reciprocalSet) : Β¬Tendsto sequence atTop (𝓝 x)
Proof
:= by
  intro h
  have hx : x.val = 0 := tendsto_nhds_unique (continuous_subtypeVal.tendsto x |>.comp h)
    tendsto_reciprocal
  exact zero_not_mem_reciprocal (hx β–Έ x.property)

theorem not_mapClusterPt_sequence

TopologyByExample.BookReciprocals.not_mapClusterPt_sequence

It has no subsequential accumulation point in that subspace either.

theorem not_mapClusterPt_sequence (x : reciprocalSet) : Β¬MapClusterPt x atTop sequence
Proof
:= by
  intro h
  exact not_tendsto_sequence x (le_nhds_of_cauchy_adhp cauchySeq_sequence h)

theorem not_completeSpace_reciprocal

TopologyByExample.BookReciprocals.not_completeSpace_reciprocal

The inherited metric is incomplete, despite the discrete topology.

theorem not_completeSpace_reciprocal : Β¬CompleteSpace reciprocalSet
Proof
:= by
  intro h
  obtain ⟨x, hx⟩ := cauchySeq_tendsto_of_complete cauchySeq_sequence
  exact not_tendsto_sequence x hx

definition reciprocalMetric

TopologyByExample.BookReciprocals.reciprocalMetric

A metric on the positive integers, indexed by n + 1, obtained from reciprocals.

@[instance_reducible]
def reciprocalMetric : MetricSpace β„•
:=
  (MetricSpace.induced reciprocal isEmbedding_reciprocal.injective inferInstance).replaceTopology
    isEmbedding_reciprocal.isInducing.eq_induced

theorem reciprocalMetric_dist

TopologyByExample.BookReciprocals.reciprocalMetric_dist

The reciprocal metric has the displayed quotient formula.

theorem reciprocalMetric_dist (n m : β„•) :
    reciprocalMetric.dist n m = |(n : ℝ) - m| / (((n : ℝ) + 1) * ((m : ℝ) + 1))
Proof
:= by
  change |reciprocal n - reciprocal m| = _
  have hn : (n : ℝ) + 1 β‰  0 := by positivity
  have hm : (m : ℝ) + 1 β‰  0 := by positivity
  have he : reciprocal n - reciprocal m =
      ((m : ℝ) - n) / (((n : ℝ) + 1) * ((m : ℝ) + 1)) := by
    unfold reciprocal
    field_simp
    ring
  rw [he, abs_div, abs_of_pos (by positivity : 0 < ((n : ℝ) + 1) * ((m : ℝ) + 1)),
    abs_sub_comm]

theorem reciprocalMetric_topology

TopologyByExample.BookReciprocals.reciprocalMetric_topology

Its topology is exactly the usual discrete topology on the integers.

theorem reciprocalMetric_topology : reciprocalMetric.toUniformSpace.toTopologicalSpace =
    (inferInstance : TopologicalSpace β„•)
Proof
:= rfl

theorem reciprocalMetric_isometry

TopologyByExample.BookReciprocals.reciprocalMetric_isometry

Reciprocation is an isometry for the new metric.

theorem reciprocalMetric_isometry :
    @Isometry β„• ℝ reciprocalMetric.toPseudoMetricSpace.toPseudoEMetricSpace
      inferInstance reciprocal
Proof
:= by
  apply (@isometry_iff_dist_eq β„• ℝ reciprocalMetric.toPseudoMetricSpace
    inferInstance reciprocal).mpr
  intro n m
  rfl

theorem reciprocalMetric_not_complete

TopologyByExample.BookReciprocals.reciprocalMetric_not_complete

This compatible metric on the positive integers is incomplete.

theorem reciprocalMetric_not_complete : Β¬@CompleteSpace β„• reciprocalMetric.toUniformSpace
Proof
:= by
  intro h
  have hc : IsClosed reciprocalSet :=
    (@Isometry.isClosedEmbedding β„• ℝ (letI := reciprocalMetric; inferInstance) h
      inferInstance reciprocal reciprocalMetric_isometry).isClosed_range
  have hz : (0 : ℝ) ∈ closure reciprocalSet := by
    rw [ClosureComplementSubsets.closure_reciprocalSet]
    exact mem_insert 0 reciprocalSet
  exact zero_not_mem_reciprocal (hc.closure_eq β–Έ hz)

theorem ordinaryMetric_complete

TopologyByExample.BookReciprocals.ordinaryMetric_complete

The same topology has its ordinary complete metric.

theorem ordinaryMetric_complete : CompleteSpace β„•
Proof
:= inferInstance

definition alternating

TopologyByExample.BookReciprocals.alternating

The alternating enumeration 1, 2, 1/2, 3/2, ....

def alternating (n : β„•) : ℝ
:=
  if n % 2 = 0 then reciprocal (n / 2) else 1 + reciprocal (n / 2)

theorem alternating_even

TopologyByExample.BookReciprocals.alternating_even

Even terms give the reciprocal sequence.

@[simp] theorem alternating_even (n : β„•) : alternating (2 * n) = reciprocal n
Proof
:= by
  simp [alternating]

theorem alternating_odd

TopologyByExample.BookReciprocals.alternating_odd

Odd terms give its translate by one.

@[simp] theorem alternating_odd (n : β„•) : alternating (2 * n + 1) = 1 + reciprocal n
Proof
:= by
  simp [alternating, Nat.mul_add_div]

theorem range_alternating

TopologyByExample.BookReciprocals.range_alternating

The range is exactly the alternating reciprocal subset.

theorem range_alternating : range alternating = AlternatingReciprocals.subset
Proof
:= by
  ext x
  constructor
  · rintro ⟨n, rfl⟩
    by_cases h : n % 2 = 0
    · exact Or.inl ⟨n / 2, by simp [alternating, h]⟩
    · exact Or.inr ⟨n / 2, by simp [alternating, h]⟩
  · rintro (⟨n, rfl⟩ | ⟨n, rfl⟩)
    · exact ⟨2 * n, alternating_even n⟩
    · exact ⟨2 * n + 1, alternating_odd n⟩

theorem infinite_alternating_in_nhds

TopologyByExample.BookReciprocals.infinite_alternating_in_nhds

Every neighbourhood of zero meets the alternating range infinitely often.

theorem infinite_alternating_in_nhds {U : Set ℝ} (hU : U ∈ 𝓝 0) :
    (U ∩ range alternating).Infinite
Proof
:= by
  rw [range_alternating]
  exact (infinite_reciprocals_in_nhds hU).mono
    (inter_subset_inter_right _ subset_union_left)

theorem accPt_alternating_range

TopologyByExample.BookReciprocals.accPt_alternating_range

Zero is an accumulation point of the range as a subset of the real line.

theorem accPt_alternating_range : AccPt (0 : ℝ) (π“Ÿ (range alternating))
Proof
:= by
  apply accPt_iff_nhds.mpr
  intro U hU
  obtain ⟨x, hxU, hx⟩ := (infinite_reciprocals_in_nhds hU).nonempty
  refine ⟨x, ⟨hxU, ?_⟩, ?_⟩
  Β· rw [range_alternating]
    exact Or.inl hx
  Β· rintro rfl
    exact zero_not_mem_reciprocal hx

theorem alternating_cluster_zero

TopologyByExample.BookReciprocals.alternating_cluster_zero

Zero is a cluster point of the alternating sequence.

theorem alternating_cluster_zero : MapClusterPt (0 : ℝ) atTop alternating
Proof
:= by
  have ht : Tendsto (fun n : β„• ↦ 2 * n) atTop atTop := by
    apply tendsto_atTop_atTop.mpr
    intro b
    exact ⟨b, fun a ha ↦ by omega⟩
  apply MapClusterPt.of_comp ht
  simpa only [Function.comp_def, alternating_even] using tendsto_reciprocal.mapClusterPt

theorem alternating_not_tendsto_zero

TopologyByExample.BookReciprocals.alternating_not_tendsto_zero

The alternating sequence does not converge to zero.

theorem alternating_not_tendsto_zero : Β¬Tendsto alternating atTop (𝓝 (0 : ℝ))
Proof
:= by
  intro h
  have ht : Tendsto (fun n : β„• ↦ 2 * n + 1) atTop atTop := by
    apply tendsto_atTop_atTop.mpr
    intro b
    exact ⟨b, fun a ha ↦ by omega⟩
  have hz : Tendsto (fun n ↦ 1 + reciprocal n) atTop (𝓝 (0 : ℝ)) := by
    simpa only [Function.comp_def, alternating_odd] using h.comp ht
  have ho : Tendsto (fun n ↦ 1 + reciprocal n) atTop (𝓝 (1 : ℝ)) := by
    simpa using tendsto_const_nhds.add tendsto_reciprocal
  have := tendsto_nhds_unique hz ho
  norm_num at this

theorem ordinary_cauchy_eventually_constant

TopologyByExample.BookReciprocals.ordinary_cauchy_eventually_constant

A usual-metric Cauchy sequence of integers is eventually constant.

theorem ordinary_cauchy_eventually_constant {u : β„• β†’ β„•} (hu : CauchySeq u) :
    βˆƒ N, βˆ€ n β‰₯ N, u n = u N
Proof
:= by
  obtain ⟨N, hN⟩ := Metric.cauchySeq_iff.mp hu 1 (by norm_num)
  refine ⟨N, fun n hn ↦ ?_⟩
  by_contra hne
  exact not_lt_of_ge (Nat.pairwise_one_le_dist hne) (hN n hn N le_rfl)

theorem reciprocalMetric_cauchy

TopologyByExample.BookReciprocals.reciprocalMetric_cauchy

The increasing integer enumeration is Cauchy for the reciprocal metric.

theorem reciprocalMetric_cauchy :
    @CauchySeq β„• β„• reciprocalMetric.toUniformSpace inferInstance (fun n ↦ n)
Proof
:= by
  apply (@Metric.cauchySeq_iff β„• β„• reciprocalMetric.toPseudoMetricSpace
    inferInstance inferInstance (fun n ↦ n)).mpr
  exact Metric.cauchySeq_iff.mp tendsto_reciprocal.cauchySeq

theorem reciprocalMetric_enumeration_not_tendsto

TopologyByExample.BookReciprocals.reciprocalMetric_enumeration_not_tendsto

That enumeration converges to no integer for the reciprocal metric.

theorem reciprocalMetric_enumeration_not_tendsto (k : β„•) :
    letI := reciprocalMetric
    Β¬Tendsto (fun n : β„• ↦ n) atTop (𝓝 k)
Proof
:= by
  let : MetricSpace β„• := reciprocalMetric
  intro h
  have hr : Tendsto reciprocal atTop (𝓝 (reciprocal k)) :=
    reciprocalMetric_isometry.continuous.tendsto k |>.comp h
  exact (ne_of_gt (reciprocal_pos k)) (tendsto_nhds_unique hr tendsto_reciprocal)