Lean library · module TopologyByExample.Theorems.CompressedMetricExamples

Further exact illustrations for the compressed real metric

Source file

Compression is nonexpansive, and the natural-number enumeration is Cauchy without a cluster point in the compressed 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 nonnegative_fraction_dist

TopologyByExample.CompressedRealMetric.nonnegative_fraction_dist

Fractional compression decreases distances between nonnegative numbers.

theorem nonnegative_fraction_dist {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) :
Proof
    |x / (1 + x) - y / (1 + y)| ≤ |x - y| := by
  have hd : 0 < (1 + x) * (1 + y) := by positivity
  have he : x / (1 + x) - y / (1 + y) = (x - y) / ((1 + x) * (1 + y)) := by
    field_simp
    ring
  rw [he, abs_div, abs_of_pos hd]
  apply (div_le_iff₀ hd).mpr
  exact le_mul_of_one_le_right (abs_nonneg _) (by nlinarith)

theorem opposite_sign_compress_dist

TopologyByExample.CompressedRealMetric.opposite_sign_compress_dist

Compression decreases distances across zero.

theorem opposite_sign_compress_dist {x y : ℝ} (hx : 0 ≤ x) (hy : y ≤ 0) :
Proof
    |compress x - compress y| ≤ |x - y| := by
  have hxp : 0 ≤ x / (1 + x) := by positivity
  have hyp : y / (1 + -y) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg hy (by linarith)
  have hxb : x / (1 + x) ≤ x := div_le_self hx (by linarith)
  have hyb : -y / (1 + -y) ≤ -y := div_le_self (by linarith) (by linarith)
  rw [compress_eq, compress_eq, abs_of_nonneg hx, abs_of_nonpos hy,
    abs_of_nonneg (by linarith : 0 ≤ x / (1 + x) - y / (1 + -y)),
    abs_of_nonneg (by linarith : 0 ≤ x - y)]
  rw [neg_div] at hyb
  linarith

theorem metric_dist_le

TopologyByExample.CompressedRealMetric.metric_dist_le

The new distance never exceeds ordinary real distance.

theorem metric_dist_le (x y : ℝ) : metric.dist x y ≤ dist x y
Proof
:= by
  change |compress x - compress y| ≤ |x - y|
  by_cases hx : 0 ≤ x
  · by_cases hy : 0 ≤ y
    · simpa only [compress_eq, abs_of_nonneg hx, abs_of_nonneg hy] using
        nonnegative_fraction_dist hx hy
    · exact opposite_sign_compress_dist hx (le_of_not_ge hy)
  · have hx' : x ≤ 0 := le_of_not_ge hx
    by_cases hy : 0 ≤ y
    · simpa only [abs_sub_comm] using opposite_sign_compress_dist hy hx'
    · have hy' : y ≤ 0 := le_of_not_ge hy
      simpa only [compress_eq, abs_of_nonpos hx', abs_of_nonpos hy', neg_div,
        neg_sub_neg, abs_sub_comm] using
        nonnegative_fraction_dist (neg_nonneg.mpr hx') (neg_nonneg.mpr hy')

theorem metric_dist_nat

TopologyByExample.CompressedRealMetric.metric_dist_nat

The distance formula on natural numbers.

theorem metric_dist_nat (n m : ℕ) :
    metric.dist (n : ℝ) m =
Proof
      |(n : ℝ) - m| / ((1 + (n : ℝ)) * (1 + (m : ℝ))) := by
  simp only [metric_dist, abs_of_nonneg (show (0 : ℝ) ≤ n by positivity),
    abs_of_nonneg (show (0 : ℝ) ≤ m by positivity)]
  have he : (n : ℝ) / (1 + n) - m / (1 + m) =
      ((n : ℝ) - m) / ((1 + n) * (1 + m)) := by
    field_simp
    ring
  rw [he, abs_div, abs_of_pos (by positivity : 0 < (1 + (n : ℝ)) * (1 + (m : ℝ)))]

theorem tendsto_compress_nat

TopologyByExample.CompressedRealMetric.tendsto_compress_nat

Compressed natural numbers tend to the missing endpoint one.

theorem tendsto_compress_nat : Tendsto (fun n : ℕ ↦ compress n) atTop (𝓝 1)
Proof
:= by
  have he (n : ℕ) : compress (n : ℝ) = 1 - 1 / ((n : ℝ) + 1) := by
    rw [compress_eq, abs_of_nonneg (Nat.cast_nonneg n)]
    field_simp
    ring
  simp_rw [he]
  simpa using tendsto_const_nhds.sub (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ))

theorem metric_cauchy_nat

TopologyByExample.CompressedRealMetric.metric_cauchy_nat

The integer enumeration is Cauchy for the compressed metric.

theorem metric_cauchy_nat :
    @CauchySeq ℝ ℕ metric.toUniformSpace inferInstance (fun n ↦ (n : ℝ))
Proof
:= by
  apply (@Metric.cauchySeq_iff ℝ ℕ metric.toPseudoMetricSpace
    inferInstance inferInstance (fun n ↦ (n : ℝ))).mpr
  exact Metric.cauchySeq_iff.mp tendsto_compress_nat.cauchySeq

theorem metric_nat_not_tendsto

TopologyByExample.CompressedRealMetric.metric_nat_not_tendsto

This Cauchy sequence has no limit in the real carrier.

theorem metric_nat_not_tendsto (x : ℝ) : ¬Tendsto (fun n : ℕ ↦ (n : ℝ)) atTop (𝓝 x)
Proof
:= by
  intro h
  have hx : compress x = 1 := tendsto_nhds_unique
    (isEmbedding_compress.continuous.tendsto x |>.comp h) tendsto_compress_nat
  exact (intervalHomeomorph x).property.2.ne hx

theorem metric_nat_not_mapClusterPt

TopologyByExample.CompressedRealMetric.metric_nat_not_mapClusterPt

It has no cluster point either.

theorem metric_nat_not_mapClusterPt (x : ℝ) :
    ¬MapClusterPt x atTop (fun n : ℕ ↦ (n : ℝ))
Proof
:= by
  intro h
  apply metric_nat_not_tendsto x
  exact @le_nhds_of_cauchy_adhp ℝ metric.toUniformSpace _ x metric_cauchy_nat h