Lean library · module TopologyByExample.Theorems.FrechetProductMetric

The weighted-sum Fréchet metric on a countable product

Source file

Coordinates start at zero, so the weight of coordinate n is 2^(-(n+1)).

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

definition weight

TopologyByExample.FrechetProductMetric.weight

The geometric weight of a zero-based coordinate.

def weight (n : ℕ) : ℝ
:= (1 / 2) ^ (n + 1)

theorem weight_pos

TopologyByExample.FrechetProductMetric.weight_pos

Every coordinate has strictly positive weight.

theorem weight_pos (n : ℕ) : 0 < weight n
Proof
:= by unfold weight; positivity

theorem summable_weight

TopologyByExample.FrechetProductMetric.summable_weight

The geometric weights are summable.

theorem summable_weight : Summable weight
Proof
:=
  summable_geometric_two.comp_injective Nat.succ_injective

theorem finite_positive_bound

TopologyByExample.FrechetProductMetric.finite_positive_bound

Finitely many positive numbers have a common positive lower bound.

private theorem finite_positive_bound (F : Finset ℕ) (r : ℕ → ℝ)
    (hr : ∀ i ∈ F, 0 < r i) : ∃ ε > 0, ∀ i ∈ F, ε ≤ r i
Proof
:= by
  classical
  induction F using Finset.induction_on with
  | empty => exact ⟨1, zero_lt_one, by simp⟩
  | @insert i F hi ih =>
    obtain ⟨ε, hε, he⟩ := ih (fun j hj ↦ hr j (Finset.mem_insert_of_mem hj))
    refine ⟨min (r i) ε, lt_min (hr i (Finset.mem_insert_self _ _)) hε, ?_⟩
    intro j hj
    rcases Finset.mem_insert.mp hj with rfl | hj
    · exact min_le_left _ _
    · exact (min_le_right _ _).trans (he j hj)
variable {X : Type*} [MetricSpace X]

definition distance

TopologyByExample.FrechetProductMetric.distance

The weighted sum of the coordinate distances.

def distance (x y : ℕ → X) : ℝ
:= ∑' n, weight n * dist (x n) (y n)
variable {B : ℝ} (hb : ∀ x y : X, dist x y ≤ B)
include hb

theorem summable_distance

TopologyByExample.FrechetProductMetric.summable_distance

Bounded coordinate distances give a summable series.

theorem summable_distance (x y : ℕ → X) : Summable (fun n ↦ weight n * dist (x n) (y n))
Proof
:= by
  apply Summable.of_nonneg_of_le (fun n ↦ mul_nonneg (weight_pos n).le dist_nonneg)
    (fun n ↦ ?_) (summable_weight.mul_right B)
  simpa using mul_le_mul_of_nonneg_left (hb (x n) (y n)) (weight_pos n).le

theorem term_le_distance

TopologyByExample.FrechetProductMetric.term_le_distance

Each weighted coordinate distance is bounded by the whole distance.

theorem term_le_distance (x y : ℕ → X) (n : ℕ) :
    weight n * dist (x n) (y n) ≤ distance x y
Proof
:=
  (summable_distance hb x y).le_tsum n (fun i _ ↦ mul_nonneg (weight_pos i).le dist_nonneg)

theorem distance_triangle

TopologyByExample.FrechetProductMetric.distance_triangle

The weighted sum satisfies the triangle inequality.

theorem distance_triangle (x y z : ℕ → X) : distance x z ≤ distance x y + distance y z
Proof
:= by
  calc
    distance x z ≤ ∑' n, (weight n * dist (x n) (y n) + weight n * dist (y n) (z n)) :=
      (summable_distance hb x z).tsum_le_tsum (fun n ↦ by
        rw [← mul_add]
        exact mul_le_mul_of_nonneg_left (dist_triangle _ _ _) (weight_pos n).le)
        ((summable_distance hb x y).add (summable_distance hb y z))
    _ = distance x y + distance y z :=
      (summable_distance hb x y).tsum_add (summable_distance hb y z)

theorem continuous_distance

TopologyByExample.FrechetProductMetric.continuous_distance

Weighted distance from a fixed point is continuous in the product topology.

theorem continuous_distance (x : ℕ → X) : Continuous (distance x)
Proof
:= by
  apply continuous_tsum (fun n ↦ ((continuous_const.dist (continuous_apply n)).const_mul _))
    (summable_weight.mul_right B)
  intro n y
  rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (weight_pos n).le dist_nonneg)]
  simpa using mul_le_mul_of_nonneg_left (hb (x n) (y n)) (weight_pos n).le

theorem distance_open_iff

TopologyByExample.FrechetProductMetric.distance_open_iff

The weighted balls give exactly the product topology.

theorem distance_open_iff (s : Set (ℕ → X)) :
    IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ∀ y, distance x y < ε → y ∈ s
Proof
:= by
  classical
  constructor
  · intro hs x hx
    obtain ⟨F, U, hU, hsub⟩ := isOpen_pi_iff.mp hs x hx
    have hex (i : ℕ) : ∃ r > 0, i ∈ F → Metric.ball (x i) r ⊆ U i := by
      by_cases hi : i ∈ F
      · obtain ⟨r, hr, hs⟩ := Metric.isOpen_iff.mp (hU i hi).1 (x i) (hU i hi).2
        exact ⟨r, hr, fun _ ↦ hs⟩
      · exact ⟨1, zero_lt_one, fun h ↦ (hi h).elim⟩
    choose r hr hball using hex
    obtain ⟨ε, hε, he⟩ := finite_positive_bound F (fun i ↦ weight i * r i)
      (fun i _ ↦ mul_pos (weight_pos i) (hr i))
    refine ⟨ε, hε, fun y hy ↦ hsub ?_⟩
    intro i hi
    apply hball i hi
    have hmul : weight i * dist (x i) (y i) < weight i * r i :=
      (term_le_distance hb x y i).trans_lt (hy.trans_le (he i hi))
    have hd : dist (x i) (y i) < r i := (mul_lt_mul_iff_right₀ (weight_pos i)).mp hmul
    simpa only [Metric.mem_ball, dist_comm] using hd
  · intro h
    apply isOpen_iff_mem_nhds.mpr
    intro x hx
    obtain ⟨ε, hε, hsub⟩ := h x hx
    have ho : IsOpen {y | distance x y < ε} :=
      isOpen_lt (continuous_distance hb x) continuous_const
    have hxball : x ∈ {y | distance x y < ε} := by simpa [distance] using hε
    exact Filter.mem_of_superset (ho.mem_nhds hxball) hsub

definition metric

TopologyByExample.FrechetProductMetric.metric

The actual Fréchet metric, with the original product topology.

@[instance_reducible]
def metric (X : Type*) [MetricSpace X] {B : ℝ} (hb : ∀ x y : X, dist x y ≤ B) :
    MetricSpace (ℕ → X)
Definition
:=
  MetricSpace.ofDistTopology distance (by intro x; simp [distance])
    (by intro x y; simp [distance, dist_comm]) (distance_triangle hb) (distance_open_iff hb)
    (by
      intro x y h
      funext n
      apply eq_of_dist_eq_zero
      have hi := term_le_distance hb x y n
      rw [h] at hi
      have hw := weight_pos n
      have hd : 0 ≤ dist (x n) (y n) := dist_nonneg
      nlinarith)

theorem metric_dist

TopologyByExample.FrechetProductMetric.metric_dist

The exact distance is the weighted sum specified in the construction.

theorem metric_dist (x y : ℕ → X) :
    (metric X hb).dist x y = ∑' n, (1 / 2 : ℝ) ^ (n + 1) * dist (x n) (y n)
Proof
:= rfl

theorem metric_topology

TopologyByExample.FrechetProductMetric.metric_topology

The weighted-sum metric induces exactly the countable product topology.

theorem metric_topology : (metric X hb).toUniformSpace.toTopologicalSpace =
    (inferInstance : TopologicalSpace (ℕ → X))
Proof
:= rfl

definition identityHomeomorph

TopologyByExample.FrechetProductMetric.identityHomeomorph

The identity identifies the weighted metric space with the countable topological product.

def identityHomeomorph :
    @Homeomorph (ℕ → X) (ℕ → X) (metric X hb).toUniformSpace.toTopologicalSpace inferInstance
:=
  Homeomorph.refl _

theorem metric_spec

TopologyByExample.FrechetProductMetric.metric_spec

The metric has the stated weighted distance and exactly the product topology.

theorem metric_spec :
    (∀ x y : ℕ → X, (metric X hb).dist x y =
      ∑' n, (1 / 2 : ℝ) ^ (n + 1) * dist (x n) (y n)) ∧
    (metric X hb).toUniformSpace.toTopologicalSpace =
      (inferInstance : TopologicalSpace (ℕ → X))
Proof
:=
  ⟨metric_dist hb, metric_topology hb⟩

On this site: Theorem: The Fréchet weighted metric induces the countable product topology