Andrew Sneap, 11 November 2021, Updated 3 May 2023 In this file I define the types of complete metric spaces, along with Cauchy and convergent sequences. \begin{code} {-# OPTIONS --safe --without-K #-} open import MLTT.Spartan renaming (_+_ to _β_) open import Naturals.Order open import Notation.Order open import UF.FunExt open import UF.PropTrunc open import UF.Subsingletons open import Rationals.Positive module MetricSpaces.Type (fe : Fun-Ext) (pe : Prop-Ext) (pt : propositional-truncations-exist) where open PropositionalTruncation pt m1a : (X : π€ Μ) β (B : X β X β ββ β π€β Μ) β π€ Μ m1a X B = (x y : X) β ((Ξ΅ : ββ) β B x y Ξ΅) β x οΌ y m1b : (X : π€ Μ) β (B : X β X β ββ β π€β Μ) β π€ Μ m1b X B = (x : X) β (Ξ΅ : ββ) β B x x Ξ΅ m2 : (X : π€ Μ) β (B : X β X β ββ β π€β Μ) β π€ Μ m2 X B = (x y : X) β (Ξ΅ : ββ) β B x y Ξ΅ β B y x Ξ΅ m3 : (X : π€ Μ) β (B : X β X β ββ β π€β Μ) β π€ Μ m3 X B = (x y : X) β (Ξ΅β Ξ΅β : ββ) β Ξ΅β < Ξ΅β β B x y Ξ΅β β B x y Ξ΅β m4 : (X : π€ Μ) β (B : X β X β ββ β π€β Μ) β π€ Μ m4 X B = (x y z : X) β (Ξ΅β Ξ΅β : ββ) β B x y Ξ΅β β B y z Ξ΅β β B x z (Ξ΅β + Ξ΅β) metric-space : (X : π€ Μ) β π€β β π€ Μ metric-space X = Ξ£ B κ (X β X β ββ β π€β Μ) , m1a X B Γ m1b X B Γ m2 X B Γ m3 X B Γ m4 X B \end{code} A space is a complete metric space if every cauchy sequence in a metric space is also a convergent sequence. Convergent and Cauchy Sequences are also defined below. In a metric space, all convergent sequences are cauchy sequences. \begin{code} bounded-sequence : (X : π€ Μ) β metric-space X β (S : β β X) β π€β Μ bounded-sequence X (B , _) S = β K κ ββ , ((x y : β) β B (S x) (S y) K) bounded-sequence-is-prop : (X : π€ Μ) β (m : metric-space X) β (S : β β X) β is-prop (bounded-sequence X m S) bounded-sequence-is-prop X m S = β-is-prop convergent-sequence : (X : π€ Μ) β metric-space X β (S : β β X) β π€ Μ convergent-sequence X (B , _) S = β x κ X , ((Ξ΅ : ββ) β Ξ£ N κ β , ((n : β) β N < n β B x (S n) Ξ΅)) cauchy-sequence : (X : π€ Μ) β metric-space X β (S : β β X) β π€β Μ cauchy-sequence X (B , _) S = (Ξ΅ : ββ) β Ξ£ N κ β , ((m n : β) β N β€ m β N β€ n β B (S m) (S n) Ξ΅) convergentβcauchy : (X : π€ Μ) β (m : metric-space X) β (S : β β X) β π€ Μ convergentβcauchy X m S = convergent-sequence X m S β cauchy-sequence X m S cauchyβconvergent : (X : π€ Μ) β metric-space X β (S : β β X) β π€ Μ cauchyβconvergent X m S = cauchy-sequence X m S β convergent-sequence X m S complete-metric-space : (X : π€ Μ) β π€β β π€ Μ complete-metric-space X = Ξ£ m κ metric-space X , ((S : β β X) β cauchyβconvergent X m S) \end{code}