1 Introduction
1.1 Functional analysis in the non-Archimedean setting
Broadly speaking, functional analysis studies vector spaces endowed with compatible algebraic and topological structures, together with the continuous linear maps between them. Historically, spaces of functions provided the main examples, but the subject also treats abstract Banach spaces, Hilbert spaces, and more general topological vector spaces. Over the classical fields
$\textbf {R}$
and
$\textbf {C}$
, one of its fundamental results is the Hahn–Banach theorem: every continuous linear functional defined on a subspace of a normed space extends to the whole space without increasing its norm.
These foundational questions continue to hold significance when
$\textbf {R}$
or
$\textbf {C}$
is replaced by a non-Archimedean field, notably the field
$\textbf {Q}_p$
of p-adic numbers and its completed algebraic closure
$\textbf {C}_p$
. Such fields play a pivotal role in modern number theory and p-adic geometry. In this context, the absolute value obeys the strong ultrametric inequality
Because this condition is strictly stronger than the standard triangle inequality, the geometric behavior of balls diverges significantly from the classical intuition, resulting in the failure or necessary modification of many standard functional analytic theorems. We refer to Section 2 for a more detailed treatment of these foundational notions and their formalization in Lean theorem prover and its mathematical library Mathlib.
A metric space is termed spherically complete if every decreasing sequence of closed balls has a non-empty intersection. While this property is trivially satisfied by finite-dimensional Banach spaces over
$\textbf {R}$
or
$\textbf {C}$
, it emerges as an indispensable condition in non-Archimedean functional analysis:
-
1. The non-Archimedean Hahn–Banach extension theorem holds true for spherically complete non-Archimedean normed vector spaces (cf. [Reference van Rooij32, Theorem 4.8]).
-
2. Not every subspace of a non-Archimedean normed vector space has an orthogonal complement. However, if the subspace is spherically complete, then it does have an orthogonal complement (cf. [Reference van Rooij32, Corollary 4.7]).
Beyond functional analysis, the concept of spherical completeness is deeply intertwined with p-adic geometry (e.g., [Reference Berkovich4, Proposition 1.4.4], [Reference Scholze and Weinstein36, Lemma 5.2.7]) and transcendental number theory (e.g., [Reference Kedlaya19, Reference Kedlaya20, Reference Wang and Yuan39]).
On the other hand, spherical completeness is a geometric rather than topological condition (cf. [Reference van Rooij32, Exercise 2.F]). This forces operations such as taking the “spherical completion” (cf. Section 7) of ultrametric spaces to be defined in a non-canonical way, in contrast to the canonical completion of metric spaces.
Given the central role of spherical completeness in these areas, and subtleties such as the non-canonicity of spherical completions, it is desirable to formalize the theory and its main consequences in a proof assistant, so that the relevant definitions, hypotheses, and proofs can be checked with a level of precision that is difficult to achieve in informal mathematics.
1.2 Lean, Mathlib, and related works
1.2.1 Overview of Lean and Mathlib.
The Lean theorem prover (cf. [Reference De Moura, Kong, Avigad, Van Doorn, Von Raumer, Felty and Middeldorp26]), or Lean for short, is an open-source interactive theorem prover and programming language based on dependent type theory. It was created by Leonardo de Moura in 2013, and the development of Lean 4 began in April 2018 [24]. The current generation, Lean 4, is designed not only as a proof assistant but also as an efficient functional programming language with metaprogramming facilities, which makes it possible to write tactics, automation, and domain-specific infrastructure within Lean itself. The system description of Lean 4 appeared in 2021 [Reference de Moura and Ullrich27], and Lean 4.0 was released in September 2023 [24].
The main mathematical library for Lean is Mathlib (cf. [37]). It is a community-maintained library covering large parts of algebra, topology, analysis, geometry, number theory, category theory, and combinatorics, together with extensive general-purpose infrastructure for rewriting, simplification, typeclass inference, and automation. As of July 2026, the official Mathlib statistics page lists 133810 definitions, 281979 theorems, and 772 contributors [23]. These numbers make Mathlib one of the largest libraries of formalized mathematics currently available.
1.2.2 p-adic mathematics and functional analysis in Mathlib.
Currently, Mathlib already contains substantial infrastructure relevant to this project. We give the following non-exhaustive list of relevant works:
-
1. Robert Y. Lewis formalized the field of p-adic numbers $\textbf {Q}_p$
and the corresponding Hensel’s lemma (cf. [Reference Lewis25]). -
2. María Inés de Frutos-Fernández formalized the field $\textbf {C}_p$
of the completed algebraic closure of
$\textbf {Q}_p$
(cf. [Reference de Frutos-Fernández, Naumowicz and Thiemann12]). -
3. Jiedong Jiang formalized Krasner’s lemma (cf. [Reference Jiang16]) and the continuity of roots (cf. [Reference Jiang17]). As a result, he was able to prove that $\textbf {C}_p$
is algebraically closed (cf. [Reference Jiang17]). -
4. Yury Kudryashov formalized the Hahn–Banach theorem for spaces over $\textbf {R}$
(cf. [Reference Kudryashov22]). -
5. Frédéric Dupuis, Robert Y. Lewis, and Heather Macbeth formalized several fundamental results (e.g., the Fréchet–Riesz representation theorem and the spectral theorem for compact self-adjoint operators) in functional analysis for spaces over $\textbf {R}$
or
$\textbf {C}$
(cf. [Reference Dupuis, Lewis, Macbeth, Andronick and de Moura10]).
Remark 1.1. There are also related formalizations in other proof assistants:
-
1. p-adic numbers have been formalized in Coq/Rocq by Álvaro Pelayo, Vladimir Voevodsky, and Michael A. Warren (cf. [Reference Pelayo, Voevodsky and Warren29, Reference Voevodsky, Ahrens, Grayson, van der Leer, Lindgren, Lumsdaine, Matthes and van der Weide38]); in HOL Light by John Harrison (cf. [Reference Harrison13]); and in Isabelle by Aaron Crighton (cf. [Reference Crighton8]).
-
2. Functional analysis—counting the Hahn–Banach theorem—has been formalized in Coq/Rocq by Marie Kerjean and Assia Mahboubi (cf. [Reference Kerjean and Mahboubi21]); in Isabelle/HOL by Gertrud Bauer (cf. [Reference Bauer2, Reference Bauer3]); and in Mizar by Bogdan Nowak and Andrzej Trybulec (cf. [Reference Nowak and Trybulec28]).
1.3 Contribution and structure of this work
In this work, we present a comprehensive formalization of results related to spherical completeness in the Lean theorem prover 4.31.0, building over Mathlib(commit fabf563).Footnote
1
The article is organized as follows: In Section 2, we give a brief overview of the relevant background in functional analysis, p-adic mathematics, and its formalization in Mathlib, which provides the reader with the necessary context. In Section 3, we introduce the formalization of spherical completeness, its equivalent definitions, and its relationship with other topological conditions. In Section 4, we formalize a criterion for non-spherical-completeness and apply it to show that
$\textbf {C}_p$
is not spherically complete. In particular, we identify and rigorously repair a gap in a classical result of Schikhof (cf. Assertion 4.2). In Section 5, we present our formalization of the notion of Birkhoff–James orthogonality for non-Archimedean normed spaces and establish the existence of orthogonal complements for spherically complete subspaces. In Section 6, we demonstrate the formalized Hahn–Banach extension theorem for non-Archimedean normed spaces. Finally, in Section 7, we present the formalization of the spherical completion of non-Archimedean normed spaces and its analytical properties.
We hope that this formalization will serve as a foundation for further developments in the field.
1.4 Future work
There are numerous potential directions for further formalization in non-Archimedean functional analysis and p-adic geometry that are related to spherically complete spaces. Among them, we highlight the following two:
1.4.1 Spherical completeness beyond metric spaces.
Spherical completeness not only serves as an important condition in non-Archimedean functional analysis, but is also deeply connected to the model theory of non-Archimedean valued fields (cf. [Reference van den Dries, Macpherson and Toffalori9, Section 4.2], [Reference Bradley-Williams and Halupczok7]). However, the valuation does not induce a distance function when its rank is greater than 1. It might not even be metrizable. To cover these cases, one may need to generalize the notion of metric space, where the distance function takes values in a totally ordered abelian group instead of the (non-negative) real numbers. The spherical completeness condition on these generalized metric spaces is not well-studied in the literature, and it would be interesting to develop the theory and formalize it in Lean.
1.4.2 Reflexivity.
Although the importance of spherical completeness in non-Archimedean functional analysis is well justified, this does not render non-spherically-complete spaces useless. On the contrary, spherical completeness is of no importance, or even detrimental, in Banach algebra or measure theory. For example, as was pointed out to the author by David Loeffler, there is no infinite-dimensional reflexive.Footnote 2 Banach space over a spherically complete ultrametric normed field (cf. [Reference van Rooij32, Theorem 4.16]). The formalization of reflexivity and its applications in non-Archimedean functional analysis is an interesting topic and a natural continuation of this work.
2 Preliminaries
This section recalls background material used throughout the article. The aim is not to give a comprehensive introduction to non-Archimedean analysis, but to fix terminology and to make clear which parts of the mathematical setting are already available in Mathlib.
2.1 Normed vector spaces over normed fields
Definition 2.1.
-
1. A pseudo-metric space $(X,d)$
is a set X equipped with a distance function
$d\colon X\times X\to \textbf {R}_{\geq 0}$
satisfying the following conditions:-
• $d(x,x)=0$
for all
$x\in X$
; -
• $d(x,y) = d(y,x)$
for all
$x,y \in X$
; -
• $d(x,z) \leq d(x,y) + d(y,z)$
for all
$x,y,z \in X$
.
It is said to be a metric space if in addition $d(x,y) = 0$
implies
$x=y$
. This is formalized as a class
PseudoMetricSpace
(resp.
MetricSpace
) in Mathlib. -
-
2. A normed field K is a field equipped with a metric d that is induced by a multiplicative norm function $\lVert \cdot \rVert \colon K\to \textbf {R}_{\geq 0}$
via
$d(x,y)=\lVert x-y\rVert $
.class NormedField (α : Type*) extends Norm α, Field α, MetricSpace α where dist_eq : ∀ x y, dist x y = norm (-x + y) protected norm_mul : ∀ a b, norm (a * b) = norm a * norm bIt is said to be non-trivial if there exists an element $a\in K$
such that
$\lVert a\rVert>1$
. This is formalized as an extended class
NontriviallyNormedField
over NormedField with single predicate. -
3. A semi-normed vector space (resp. normed vector space) E over a normed field K is a vector space equipped with a pseudo-metric (resp. metric) d that is induced by a semi-norm (resp. norm) function $\lVert \cdot \rVert \colon E\to \textbf {R}_{\geq 0}$
via
$d(x,y)=\lVert x-y\rVert $
, satisfying that for any
$c\in K$
and
$v\in E$
, we have
$\lVert c\cdot v\rVert =\lVert c\rVert \cdot \lVert v\rVert $
. This is formalized as a class
NormedSpace
, which should be used in cooperation with
SeminormedAddCommGroup
(resp.
NormedAddCommGroup
) in Mathlib.
Remark 2.2. The class NormedSpace in Mathlib only requires SeminormedAdd CommGroup as an implicit argument instead of NormedAddCommGroup. As a result, NormedSpace itself should be understood as a semi-normed space in the usual literature. In this work, part of the results around normed vector spaces are formalized in the semi-normed setting for generality, but we state most of them for normed vector spaces in this article for simplicity.
Remark 2.3. Although not used in this article, it is worth mentioning that Banach spaces, that is, the complete normed vector spaces, are not represented by a standalone class, but a combination of NormedSpace and CompleteSpace .
One can consider the subspaces and quotient spaces of a semi-normed vector space E over a normed field K. Obviously, a subspace of E (
Submodule K E
in Mathlib) automatically inherits the norm from E. On the other hand, the quotient space
$E/D$
by a subspace
$D\subseteq E$
carries the quotient semi-norm
This is realized in Mathlib as an instance Submodule.Quotient.normedSpace , and the formula is reflected in the lemma QuotientGroup.norm_mk .
For (semi-)normed vector spaces
$E,F$
over K, any continuous linear map
$T\colon E\longrightarrow F$
can be endowed with the operator norm, which is defined as the infimum of the non-negative real numbers c such that
$\lVert T(x)\rVert \leq c\cdot \lVert x\rVert $
for all
$x\in E$
. This is formalized in Mathlib under the name
ContinuousLinearMap.opNorm
, and one can use the notation T to denote the operator norm of T. The set of all continuous linear maps from E to F, denoted by
$\mathcal{L} (E,F)$
, forms a (semi-)normed vector spaces over K under the operator norm. This is formalized in Mathlib under the name
ContinuousLinearMap.toNormedSpace
.
2.2 Non-Archimedean property and number-theoretic preliminaries
Definition 2.4. A metric space
$(X,d)$
is non-Archimedean or ultrametric if for any
$x,y,z\in X$
, we have
This is defined as a class IsUltrametricDist in Mathlib.
Ultrametric spaces carry many interesting properties that are not shared by general metric spaces. For example, a frequently used result in this work is that any two closed balls in an ultrametric space are either disjoint or one is contained in the other. This is formalized in Mathlib under the name IsUltrametricDist.closedBall_subset_trichotomy .
closedBall x r ⊆ closedBall y s ∨ closedBall y s ⊆ closedBall x r ∨
Disjoint (closedBall x r) (closedBall y s)
One of the most important motivating examples of ultrametric spaces are the p-adic fields.
Definition 2.5. Let p be a prime number.
-
1. The p-adic valuation of an integer $n\in \textbf{Z} $
is defined as $$ \begin{align*}v_p(n)\mathrel{\mathop:}= \max\{k\in\textbf{N} \colon p^k \mid n\}\in \textbf{N}\cup\{+\infty\},\end{align*} $$where we set $v_p(0)\mathrel {\mathop :}= +\infty $
.
-
2. For a rational number $q=a/b\in \textbf {Q}$
with
$a,b\in \textbf{Z} $
, the p-adic norm of q is defined as $$ \begin{align*}\lVert q\rVert_p\mathrel{\mathop:}= p^{-v_p(a)+v_p(b)}.\end{align*} $$When $q=0$
, we regard
$\lVert 0\rVert _p$
as
$0$
.
-
3. The field $\textbf {Q}_p$
of p-adic rational numbers is defined to be the completion of
$\textbf {Q}$
with respect to the p-adic norm. The field
$\textbf {Q}_p$
is denoted by
ℚ_[p]
in Mathlib.
It is easy to verify, and is already formalized in Mathlib as instance
Padic.instIsUltrametricDist
, that the p-adic norm on
$\textbf {Q}_p$
is ultrametric.
The p-adic norm extends uniquely to the algebraic closure
$\textbf {Q}^{\mathrm {alg}}_p$
of
$\textbf {Q}_p$
(
PadicAlgCl p
in Mathlib). However, a non-trivial fact is that
$\textbf {Q}^{\mathrm {alg}}_p$
is not complete with respect to the extended p-adic norm (cf. [Reference Robert31, Section 1.4]). This allows us to enlarge
$\textbf {Q}^{\mathrm {alg}}_p$
to its completion, which is denoted by
$\textbf {C}_p$
(
ℂ_[p]
in Mathlib). Basic properties of
$\textbf {C}_p$
are already formalized in Mathlib, including the fact that the extended p-adic norm on
$\textbf {C}_p$
is ultrametric.
Remark 2.6. At the moment when the initial version of this project was finished with Lean 4.28 over Mathlib (Commit 8f9d9cf), there was a design flaw in the definition of the norm on
$\textbf {C}_p$
in Mathlib. The completion process automatically endows
$\textbf {C}_p$
with the extended norm, but another (mathematically identical, yet not Lean-semantically identical) norm, coming from the p-adic valuation, was written manually. This caused a diamond issue in the typeclass inference of Lean. It was fixed in a later version of Mathlib by Jiedong Jiang (cf. [Reference Jiang18]).
2.3 Conventions and notations
In the rest of this article, we adopt the following conventions and notations:
-
• p will always denote a prime number.
-
• $(\mathbb{K} ,\lVert \cdot \rVert )$
will be a non-trivially ultrametric normed field. Unless otherwise specified, any other fields appearing in this article are not assumed to be ultrametric. -
• By a normed space over $\mathbb{K} $
, we mean an ultrametric normed vector space over
$\mathbb{K} $
. -
• By a ball in a metric space, we always mean a closed ball with non-negative radius.
-
• For a vector space E over $\mathbb{K} $
and an element
$a\in E$
, we denote by
$[a]$
the subspace of E generated by a. -
• For a metric space $(X,d)$
, an element
$x\in X$
, and a subset
$A\subseteq X$
, we denote by
$d(x,A)$
the distance from x to A, that is,
$d(x,A)\mathrel {\mathop :}= \inf _{y\in A} d(x,y)$
. In Mathlib, this is named as
Metric.infDist
.
Remark 2.7. Some results in this article for metric spaces (resp. normed spaces over
$\mathbb{K} $
) can be slightly generalized for pseudo-metric spaces (resp. semi-normed spaces over
$\mathbb{K} $
), as we do in the formalization. However, we only state and prove the results for metric spaces (resp. normed spaces over
$\mathbb{K} $
) in this article for simplicity.
3 Basic properties of spherically complete spaces
3.1 Definitions and basic operations
As mentioned in the introduction, a metric space is said to be spherically complete if every decreasing sequence of closed balls has a non-empty intersection. This is formalized as follows:
class SphericallyCompleteSpace (α : Type*) [PseudoMetricSpace α] : Prop where
nonempty_iInter_of_antitone : ∀ ⦃ci : ℕ → α⦄, ∀ ⦃ri : ℕ → ℝ≥0⦄,
Antitone (fun i => closedBall (ci i) (ri i)) →
(⋂ i, closedBall (ci i) (ri i)).Nonempty
Here, Antitone means that the sequence of closed balls is decreasing.
Remark 3.1. Note that Metric.closedBall takes an arbitrary real number as its radius. To ensure that the balls are non-empty, that is, that the radius is non-negative, we use ℝ≥0 , the type of non-negative real numbers in Mathlib, instead of Real . As a result, an implicit coercion from ℝ≥0 to Real is applied when calling closedBall.
Example 3.2. The most basic examples of spherically complete spaces are the fields
$\textbf {R}$
or
$\textbf {C}$
with the standard norm and the field
$\textbf {Q}_p$
of p-adic numbers with the p-adic norm. We will show in Section 3.2.2 that the spherical completeness of these fields can be proved in a unified way.
In practice, it is often more convenient to work with sequences of balls with decreasing radius, which is equivalent to the above definition.
Theorem 3.3 (cf. [Reference van Rooij32, Lemma 2.3]).
For an ultrametric space
$(X,d)$
, the following are equivalent:
-
1. X is spherically complete.
-
2. Every sequence of balls with strictly decreasing radius has a non-empty intersection.
-
3. Any collection of balls with pairwise non-empty intersection has a non-empty intersection.
This theorem is formalized in Lean as follows:
theorem SphericallyCompleteSpace.iff_strictAnti_radius : -- (1) $\Leftrightarrow$ (2)
SphericallyCompleteSpace α ↔
∀ ⦃ci : ℕ → α⦄, ∀ ⦃ri : ℕ → NNReal⦄, StrictAnti ri →
Antitone (fun i ↦ closedBall (ci i) (ri i)) →
(⋂ i, closedBall (ci i) (ri i)).Nonempty
theorem SphericallyCompleteSpace.iff_pairwise_inter_nonempty : -- (1) $\Leftrightarrow$ (3)
SphericallyCompleteSpace α ↔
(∀ S : Set (α × NNReal), S.Nonempty →
(∀ w1 w2 : ↑S, (closedBall w1.val.1 w1.val.2 ∩ closedBall w2.val.1 w2.val.2).Nonempty) →
(⋂ w : ↑S, closedBall w.val.1 w.val.2).Nonempty)
We conclude this section by recalling the following properties of spherically complete spaces, which are easy to prove and formalize, and useful in practice.
Proposition 3.4.
-
1. The product of finitely many spherically complete metric spaces is again spherically complete.
-
2. Spherical completeness is preserved under isometric isomorphisms.
-
3. Any quotient of a spherically complete normed space over $\mathbb{K} $
is spherically complete.
This theorem is formalized in this project as follows:
-- Product of 2 spherically complete spaces is still spherically complete
instance Prod.sphericallyCompleteSpace {E F : Type*}
[PseudoMetricSpace E] [PseudoMetricSpace F]
[SphericallyCompleteSpace E] [SphericallyCompleteSpace F] :
SphericallyCompleteSpace (E × F)
-- Product of a finite family of spherically complete spaces is still spherically complete
instance Pi.sphericallyCompleteSpace {ι : Type*} [Fintype ι] {E : ι → Type*}
[∀ i, PseudoMetricSpace (E i)] [∀ i, SphericallyCompleteSpace (E i)] :
SphericallyCompleteSpace (∀ i, E i)
-- Spherical completeness is preserved under isometric isomorphisms
theorem SphericallyCompleteSpace.of_isometryEquiv {E F : Type*}
[PseudoMetricSpace E] [PseudoMetricSpace F]
[SphericallyCompleteSpace E]
(f : E ≃ᵢ F) : SphericallyCompleteSpace F
-- Any quotient of spherically complete normed spaces over 𝕂 is spherically complete
theorem Quotient.sphericallyCompleteSpace (𝕜 : Type*) [NontriviallyNormedField 𝕜]
{E : Type*} [SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
[IsUltrametricDist E] [SphericallyCompleteSpace E]
{F : Submodule 𝕜 E} :
SphericallyCompleteSpace (E ⧸ F)
3.2 Relation with other topological conditions
3.2.1 Completeness.
It is a classical result that a metric space is complete if and only if every decreasing sequence of closed balls with radius tending to zero has a non-empty intersection, which is formalized as an external lemma in our project:
theorem completeSpace_iff_nonempty_iInter_closedBall_of_tendsto_zero
(α : Type*) [PseudoMetricSpace α] :
CompleteSpace α ↔
∀ ⦃ci : ℕ → α⦄ ⦃ri : ℕ → NNReal⦄,
Antitone (fun i ↦ closedBall (ci i) (ri i)) →
Filter.Tendsto ri atTop (nhds 0) →
(⋂ i, closedBall (ci i) (ri i)).Nonempty
As an immediate corollary, every spherically complete space is complete, and this is formalized as an instance in our project.
Remark 3.5. As suggested by the anonymous referee, we assign this instance a lower priority than the default one, so that Lean is less likely to prove the completeness of a space via spherical completeness, which is rarely needed in practice.
3.2.2 Properness.
The condition of spherical completeness is fulfilled in various contexts that arise in different settings:
-
1. A subspace of a locally compact normed vector space over a complete non-trivially normed field is spherically complete.
-
2. Finite-dimensional subspaces of normed vector spaces over locally compact non-trivially normed fields are spherically complete. Note that this implies that every finite-dimensional normed space over $\textbf {R}$
,
$\textbf {C}$
, and
$\textbf {Q}_p$
is spherically complete. -
3. Compact metric spaces are spherically complete.
-
4. The complex upper half-plane, equipped with the hyperbolic metric, is spherically complete.
It is possible, but very inefficient, to formalize these results individually in Lean. Instead, we observe that all these metric spaces are proper, that is, every closed ball is compact. As a result, the spherical completeness of these spaces follows from Cantor’s intersection theorem (cf. [Reference Apostol1, Theorem 3.25]), that is, the fact that the intersection of a decreasing sequence of non-empty compact sets is non-empty:
instance instSphericallyCompleteSpaceOfProperSpace (α : Type*)
[PseudoMetricSpace α] [ProperSpace α] : SphericallyCompleteSpace α where
nonempty_iInter_of_antitone := by
intro ci ri hanti
exact IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed
(fun i ↦ closedBall (ci i) ↑(ri i)) -- chain of balls
(fun _ ↦ hanti (by linarith)) -- the chain is descending
(fun h ↦ nonempty_closedBall.mpr (ri h).prop) -- balls are non-empty
(isCompact_closedBall (ci 0) ↑(ri 0)) -- the first ball is compact
fun _ ↦ isClosed_closedBall -- all balls are closed
Remark 3.6. The properness of the aforementioned metric spaces is already formalized in Mathlib. With this instance, Lean can automatically infer the spherical completeness of these spaces without extra effort.
4 Non-examples: Separable spherically dense ultrametric spaces
Among complete valued fields,
$\textbf {C}_p$
, the completion of the algebraic closure of
$\textbf {Q}_p$
, is of particular importance in p-adic geometry. It is therefore desirable to formalize the non-spherical completeness of
$\textbf {C}_p$
in Lean.
4.1 A second glance at a result of Schikhof
Definition 4.1.
-
1. A metric space $(X,d)$
is said to have dense metric, if for any ball B in X, the set
$d(B\times B)$
is dense in
$[0,\mathrm {diam}(B)]$
.class IsDenseMetric (α : Type*) [MetricSpace α] : Prop where dense_metric : ∀ z : α, ∀ r : ℝ≥0, closure (Set.image2 dist (closedBall z r) (closedBall z r)) = Set.Icc 0 (diam (closedBall z r)) -
2. A topological space is separable if it has a countable dense subset.
Schikhof provides a proof of the following assertion.
Assertion 4.2 (cf. [Reference Schikhof33, Theorem 20.5]).
Separable ultrametric spaces with dense metric are not spherically complete.
When formalizing this result in Lean, we find that the denseness of the metric is not enough to ensure non-spherical completeness. In particular, a metric space consisting of a single point trivially has dense metric and is separable, but it is also spherically complete, as there is only one ball in this space.
Remark 4.3. To present this counterexample accurately, we establish instances for PUnit, which is the Type representing a single point.
-- Single point space is a separable ultrametric space with dense metric.
example : SeparableSpace PUnit := inferInstance
example : IsDenseMetric PUnit := inferInstance
example : IsUltrametricDist PUnit := inferInstance
-- Single point space is spherically complete, which disproofs Schikhof's result.
example : SphericallyCompleteSpace PUnit := inferInstance
Remark 4.4. The single point space is not the only counterexample to Schikhof’s result. For instance, see [Reference Schoeneberg35] for a more non-trivial counterexample constructed by Torsten Schoeneberg.
To isolate the issue, we revisit Schikhof’s proof. Suppose, for contradiction, that
$(X,d)$
is a spherically complete separable ultrametric space with dense metric. Let
$\{a_0,a_1,\ldots \}$
be a countableFootnote
3
dense subset of X. Take
$r_0>0$
to be the distance between two distinct points of X, and take a sequence of real numbers
$r_1,r_2,\ldots $
such that
$r_0>r_1>\cdots >r_n>\cdots >\frac {1}{2}r_0$
.
Schikhof’s proof depends on the following claim.
Claim 4.5. Let
$x\in X$
and let
$B\subseteq X$
be a ball with
$\mathrm {diam}(B)>0$
or X itself. For any
$r'\in (0,\mathrm {diam}(B))$
, there exists a ball
$B'\subseteq B$
with
$\mathrm {diam}(B')=r'$
such that
$x\notin B'$
.
With this claim, one can recursively construct a decreasing sequence of balls
${B_1\supseteq B_2\supseteq \cdots \supseteq B_n\supseteq \cdots }$
such that
$\mathrm {diam}(B_n)=r_n$
and
$a_{n-1}\notin B_n$
for each
${n\geq 1}$
. The spherical completeness of X implies that
$\bigcap _{n=1}^\infty B_n$
is non-empty and consequently contains a non-empty ball of radius
$\frac {1}{2}r_0>0$
. This ball is disjoint from the dense set
$\{a_0,a_1,\ldots \}$
, which leads to a contradiction.
The subtlety appears in the proof of Claim 4.5. Schikhof partitions B into at least two disjoint balls of radius
$r'$
via the relation
$x\sim y \Longleftrightarrow d(x,y)\leq r'$
, and one of them, say
$B'$
, does not contain x. Although this is sound, it is not clear why
$\mathrm {diam}(B')=r'$
. The denseness of the metric only ensures that there are subballs of B with diameter arbitrarily close to
$r'$
; it does not guarantee that the distances approximating
$r'$
from below can always be realized between points in the same subball, let alone that we can find such a subball that does not contain x.
To fix this issue, we introduce a stronger condition than the denseness of the metric.
Definition 4.6. A metric space is spherically dense if for any ball B, its diameter equals the radius.
class IsSphericallyDense (α : Type*) [PseudoMetricSpace α] : Prop where
spherically_dense : ∀ (c : α) (r : ℝ≥0) , diam (closedBall c r) = r
Theorem 4.7. Let
$(X,d)$
be a separable spherically dense ultrametric space. Then Claim 4.5 holds. In particular, X is not spherically complete.
Proof. Since
$r'<\mathrm {diam}(B)$
, one can take
$x_1,x_2\in B$
such that
$d(x_1,x_2)>r'$
. Consider the balls
$B(x_1,r')$
and
$B(x_2,r')$
. The ultrametric inequality ensures that these two balls are disjoint, and consequently at least one of them does not contain x. The spherical denseness of X ensures that the diameter of this ball equals
$r'$
.
In our project, Claim 4.5 is formalized as follows:
lemma exists_sub_closedBall_not_mem {α : Type*}
[PseudoMetricSpace α] [IsUltrametricDist α] [IsSphericallyDense α]
(c₀ : α) (r₀ : ℝ≥0) (r₁ : ℝ≥0) (hr : r₁ < r₀) (z : α) :
∃ c₁ : α,
closedBall c₁ r₁ ⊆ closedBall c₀ r₀ ∧
z ∉ closedBall c₁ r₁osedBall c₁ r₁ ⊆ closedBall c₀ r₀ ∧ z ∉ closedBall c₁ r₁
And the non-spherical completeness of separable spherically dense ultrametric spaces is formalized as follows:
theorem not_sphericallyCompleteSpace_of_isSphericallyDense_separable_ ultrametric
(α : Type*) [MetricSpace α]
[IsUltrametricDist α] [IsSphericallyDense α] [Nonempty α] [SeparableSpace α] :
¬ SphericallyCompleteSpace α
The following proposition shows that spherical denseness is a reasonable replacement for the dense metric condition and is satisfied by the important example
$\textbf {C}_p$
.
Proposition 4.8. Let
$(X,d)$
be an ultrametric space.
-
1. If X is spherically dense, then it has dense metric. The converse is not true.
theorem IsDenseMetric.of_isSphericallyDense (α : Type*) [MetricSpace α] [IsUltrametricDist α] [IsSphericallyDense α] : IsDenseMetric α -
2. If $(F,\lVert \cdot \rVert )$
is a normed field, then the following are equivalent:-
(a) F is spherically dense.
-
(b) F is a densely normed field, that is, for any positive real numbers $r_1<r_2$
, there exists
$z\in F$
such that
$r_1<\lVert z\rVert <r_2$
. -
(c) F has dense metric.
instance instIsSphericallyDenseOfDenselyNormedField (α : Type*) [DenselyNormedField α] [IsUltrametricDist α] : IsSphericallyDense instance instDenselyNormedFieldOfIsSphericallyDenseOfUltrametricNormed Field (α : Type*) [NormedField α] [IsUltrametricDist α] [IsSphericallyDense α] : DenselyNormedField αtheorem IsDenseMetric.iff_isSphericallyDense_of_normedField (α : Type*) [NormedField α] [IsUltrametricDist α] : IsDenseMetric α ↔ IsSphericallyDense α -
Proof.
-
1. Suppose that $(X,d)$
is spherically dense. Let B be a ball in X with
$\mathrm {diam}(B)>0$
, that is, it contains at least two different points
$x,y\in B$
. For any real numbers
$r_1<r_2$
in the interval
$[0,\mathrm {diam}(B)]$
, consider the ball
$B'\mathrel {\mathop :}= B\left (x,\frac {r_1+r_2}{2}\right )$
. The ultrametric inequality ensures that
$B'$
is contained in B. The spherical denseness of X implies that
$\mathrm {diam}(B')=\frac {r_1+r_2}{2}$
. As a result, one can take
$z_1,z_2\in B'\subseteq B$
such that
$d(z_1,z_2)=\frac {r_1+r_2}{2}\in (r_1,r_2)$
. This shows that
$d(B\times B)$
is dense in
$[0,\mathrm {diam}(B)]$
.The space consisting of a single point is a counterexample to the converse.
-
2. By (1), we only need to show the equivalence between (2a) and (2b), and that (2c) implies (2b).
Suppose that F is spherically dense. For any positive real numbers ${r_1<r_2}$
, consider the ball
$B\mathrel {\mathop :}= B\left (0,\frac {r_1+r_2}{2}\right )$
. The spherical denseness of F implies that
$\mathrm {diam}(B)=\frac {r_1+r_2}{2}$
. As a result, one can take
$x,y\in B$
such that
$d(x,y)= \lVert x-y\rVert \in \left (r_1,\frac {r_1+r_2}{2}\right )$
. This proves that (2a) implies (2b).Conversely, suppose that F is a densely normed field. Let $B\mathrel {\mathop :}= B(z,r)$
be a ball in F with
$r>0$
. For any
$\epsilon>0$
, the denseness of the norm ensures that there exists
$w\in F$
such that $$ \begin{align*}r-\epsilon<\lVert w\rVert=d(z,z+w)<r.\end{align*} $$This shows that $z+w\in B$
and
$\mathrm {diam}(B)\geq r-\epsilon $
. The implication (2b)
$\Rightarrow $
(2a) follows by letting
$\epsilon $
tend to zero.
Now we suppose F has dense metric. We first claim that F is non-trivially valued, that is, there exists $w\in F$
such that
$\left \lVert w\right \rVert>1$
. Consider the unit ball
$B_0=B(0,1)$
. Since
$\mathrm {diam}(B_0)\geq \left \lVert 1-0\right \rVert =1$
, the ultrametric inequality implies that
$\mathrm {diam}(B_0)=1$
. Thus the dense metric ensures the existence of
$z_1,z_2\in B_0$
such that
$d(w_1,w_2)=\left \lVert w_1-w_2\right \rVert \in (\frac {1}{2},1)$
. Then taking
${w=(w_1-w_2)^{-1}}$
gives
$\left \lVert w\right \rVert>1$
. To show that F is a densely normed field, let
$r_1<r_2$
be two positive real numbers. By the claim, one takes an integer
$n>0$
large enough such that
$R\mathrel {\mathop :}= \left \lVert w\right \rVert ^n>r_2$
. By similar reasoning as above, one knows that
$\mathrm {diam}(B(0,R))=R$
. Since
$(r_1,r_2)\subseteq [0,R]$
, the dense metric ensures that there exists
$z_1,z_2\in B(0,R)$
such that
$d(z_1,z_2)=\left \lVert z_1-z_2\right \rVert \in (r_1,r_2)$
; then
$z=z_1-z_2\in F$
satisfies
$r_1<\left \lVert z\right \rVert <r_2$
, which finishes the proof.
Remark 4.9. We do not formalize the equivalence of spherical denseness and dense metric condition for normed fields as instances. This is because the class IsDenseMetric is not supposed to be used anywhere else in the project, and instances for it may slow down the type inference of Lean.
4.2 The non-spherical completeness of
$\textbf {C}_p$
Fix a prime number p:
variable (p : ℕ) [hp : Fact (Nat.Prime p)]
To apply Theorem 4.7 to
$\textbf {C}_p$
in Lean, one needs to provide the instances of DenselyNormedField and TopologicalSpace.SeparableSpace for
$\textbf {C}_p$
, which are not yet formalized in Mathlib. In this section, we demonstrate our implementation of these two instances.
4.2.1 Norm-denseness of
$\textbf {C}_p$
.
Mathematically speaking, it is fairly easy to show that
$\textbf {C}_p$
is a densely normed field: for any positive real numbers
$r_1<r_2$
, one can take a rational number r such that
$r_1<\lVert p\rVert ^r<r_2$
. Then
$p^r$
is an element of
$\textbf {C}_p$
with norm in
$(r_1,r_2)$
. To formalize this, we divide the proof into the following steps:
-
1. For real numbers $b>a\geq 0$
, there exists a rational number
$r=\frac {u}{v}$
with
$\gcd (u,v)=1$
such that
$a<\lVert p\rVert ^r<b$
, where p is viewed as an element in
$\textbf {Q}^{\mathrm {alg}}_p$
.lemma exists_rat_pow_p_norm_between {a b : ℝ} (ha : 0 ≤ a) (hab : a < b) : ∃ c : ℚ, a < ‖(p : (PadicAlgCl p))‖ ^ (c : ℝ) ∧ ‖(p : (PadicAlgCl p))‖ ^ (c : ℝ) < bThere is nothing new in the proof: take the logarithm with base $\lVert p\rVert $
and use the density of
$\textbf {Q}$
in
$\textbf {R}$
. -
2. Let $f(X)=X^v-p^u\in \textbf {Q}^{\mathrm {alg}}_p[X]$
, and let
$z\in \textbf {Q}^{\mathrm {alg}}_p$
be a root of f. Then one has
$z^v=p^u$
, and consequently
$\lVert z\rVert ^v=\lVert p\rVert ^u$
, that is,
$\lVert z\rVert =\lVert p\rVert ^r$
. This shows that
$\textbf {Q}^{\mathrm {alg}}_p$
is a densely normed field.instance instDenselyNormedFieldPadicAlgCl : DenselyNormedField (PadicAlgCl p) where lt_norm_lt a b ha hab := by rcases exists_rat_pow_p_norm_between p a b ha hab with ⟨r, hr1, hr2⟩ let f : Polynomial (PadicAlgCl p) := X ^ r.den - C ((p : PadicAlgCl p) ^ r.num) -- r.den = v, r.num = u ... rcases IsAlgClosed.exists_root f hf with ⟨z, hz⟩ -- hf : f.degree ≠ 0 ... have hz' : ‖z‖ = ‖(p : PadicAlgCl p)‖ ^ (↑r : ℝ) := ... use z; exact ... -
3. Provide an instance to show that the completion of a densely normed field is still densely normed:
instance instDenselyNormedFieldCompletion {α : Type*} [DenselyNormedField α] [CompletableTopField α] : DenselyNormedField (UniformSpace.Completion α)
After these preparations, the instance DenselyNormedField ℂ_[p] can be automatically inferred by inferInstance.
4.2.2 Separability of
$\textbf {C}_p$
.
It is easy to see, and is already formalized in Mathlib, that the completion of a separable metric space is still separable. Therefore, it suffices to show that
$\textbf {Q}^{\mathrm {alg}}_p$
is separable.
The approach is as follows:
-
1. Take the algebraic closure $\textbf {Q}^{\mathrm {alg}}$
of
$\textbf {Q}$
as a subset of
$\textbf {Q}^{\mathrm {alg}}_p$
. Show that
$\textbf {Q}^{\mathrm {alg}}$
is countable.Although it is mathematically trivial that $\textbf {Q}^{\mathrm {alg}}$
is a subfield of
$\textbf {Q}^{\mathrm {alg}}_p$
, this is not the case in Mathlib, as AlgebraicClosure ℚ and AlgebraicClosure ℚ_[p] are defined as two individual types. At first glance, one may want to use the fact that for any fields
$F_1,F_2$
, a non-zero morphism
$F_1\longrightarrow F^{\mathrm {alg}}_2$
can always be extended to a morphism
$F^{\mathrm {alg}}_1\longrightarrow F^{\mathrm {alg}}_2$
. In particular, there exists an embedding
$\textbf {Q}^{\mathrm {alg}}\hookrightarrow \textbf {Q}^{\mathrm {alg}}_p$
, and one can then work with the image of this embedding.Set.range <| @IsAlgClosed.lift (PadicAlgCl p) _ _ ℚ _ (AlgebraicClosure ℚ) _ _ _ _ _ _ _ -- : Set (PadicAlgCl p)In practice, we find the set $\{z\in \textbf {Q}^{\mathrm {alg}}_p \vert z \text { is algebraic over } \textbf {Q}\}$
{z : PadicAlgCl p | IsAlgebraic z}more convenient to work with, as one can easily talk about the minimal polynomial of an element of this set over $\textbf {Q}$
, as well as its roots, in Lean without passing through any field morphisms. Moreover, the countability of this set can be proved in one line by
Algebraic.countable
in Mathlib, which states that the set of algebraic elements (in a given extension field) over a countable field is countable. -
2. Fix $z\in \textbf {Q}^{\mathrm {alg}}_p$
with minimal polynomial
$f(X)\in \textbf {Q}_p[X]$
over
$\textbf {Q}_p$
. The continuity of roots (cf. [Reference Bosch, Güntzer and Remmert5, Section 3.4.1, Proposition 1]) ensures that if we approximate f closely enough by polynomials over
$\textbf {Q}$
with respect to the Gauss normFootnote
4
(which is always possible since
$\textbf {Q}$
is dense in
$\textbf {Q}_p$
), then z can be approximated by roots of these polynomials, which are elements of
$\textbf {Q}^{\mathrm {alg}}$
. This shows that
$\textbf {Q}^{\mathrm {alg}}$
is dense in
$\textbf {Q}^{\mathrm {alg}}_p$
.
Remark 4.10. In the initial version of this project, the continuity of roots was implemented as an internal result \faExternalLink* by the author. A more general variant of this result is now available in Mathlib, due to the work of Jiedong Jiang (cf. [Reference Jiang17]), under the name exists_monic_and_natDegree_eq_and_norm_map_algebraMap_coeff_sub_lt . We then adopt this new version in our project to simplify the code.
5 Birkhoff–James orthogonality
In this and the following sections, we once and for all fix a non-trivially normed field
$\mathbb{K} $
, two normed spaces
$E,F$
over
$\mathbb{K} $
, and a
$\mathbb{K} $
-linear subspace D of E.
(𝕜 : Type*) [NontriviallyNormedField 𝕜]
(E : Type*) [SeminormedAddCommGroup E] [NormedSpace 𝕜 E] [IsUltrametricDist E]
(F : Type*) [SeminormedAddCommGroup F] [NormedSpace 𝕜 F] [IsUltrametricDist F]
(D : Submodule 𝕜 E)
All code snippets in this and the following sections are formalized under these assumptions, except for:
-
1. some of the variables 𝕜, E, F, and D are made implicit to simplify the call site;
-
2. in some places, one may need to replace SeminormedAddCommGroup with NormedAddCommGroup to ensure that the norm is non-degenerate, which is required by certain results.
These differences will not be explicitly indicated in this article, for simplicity.
5.1 Definition and basic properties
In Hilbert spaces over
$\textbf {R}$
or
$\textbf {C}$
, the orthogonality between two vectors
$x,y$
is defined via the inner product. However, there is no inner product in the ultrametric world: the parallelogram law fails in general.Footnote
5
The concept of Birkhoff–James orthogonality provides a way to define an orthogonality in normed spaces without inner products.
Definition 5.1 (cf. [Reference James15]).
Let E be a normed space over a normed field K (not necessarily ultrametric). For any
$x,y\in E$
, we say that x is Birkhoff–James orthogonal to y, if
$\lVert x\rVert \leq \lVert x+\lambda y\rVert $
is satisfied for every
$\lambda \in K$
.
Remark 5.2. When there is an inner product on E, the Birkhoff–James orthogonality coincides with the usual orthogonality defined via the inner product.
In [Reference van Rooij32] and in our project, the Birkhoff–James orthogonality is restated as follows.
Definition 5.3. Let E be a normed space over
$\mathbb{K} $
. Let
$x,y$
be two elements in E and let
$V, W$
be two linear subspaces of E. We say that
-
1. x is orthogonal to V, denoted by $x \perp _{\textrm {m}} V$
, if
$\left \lVert x\right \rVert =d(x,V)$
; -
2. x is orthogonal to y, denoted by $x \perp _{\textrm {m}} y$
, if
$x \perp _{\textrm {m}} [y]$
, where
$[y]$
is the linear subspace generated by y; -
3. V is orthogonal to W, denoted by $V \perp _{\textrm {s}} W$
, if for any
$v\in V$
, one has
$v \perp _{\textrm {m}} W$
.
This is formalized in our project as follows:
def IsMOrtho (x : E) (D : Subspace 𝕜 E) := Metric.infDist x D = ‖x‖
def IsVOrtho (x y : E) := Metric.infDist x (𝕜 ∙ y) = ‖x‖
def IsOrtho (F1 : Subspace 𝕜 E) (F2 : Subspace 𝕜 E) := ∀ x ∈ F1, IsMOrtho 𝕜 x F2
notation:50 x " ⟂ₘ " F => IsMOrtho _ x F
notation:50 F " ⟂ₛ " G => IsOrtho _ F G
notation:50 x " ⟂[" 𝕜 "] " y => IsVOrtho 𝕜 x y
Various properties of the Birkhoff–James orthogonality—symmetry, homogeneity, etc.—are formalized in our project. Among them, we prove that this formulation of orthogonality is equivalent to James’s original definition:
lemma IsVOrtho.iff_birkhoffJames (x y : E) : (x ⟂[𝕜] y) ↔ ∀ c : 𝕜, ‖x‖ ≤ ‖x + c • y‖
5.2 Orthogonal projection and orthogonal complement
Definition 5.4. Let E be a normed space over
$\mathbb{K} $
, and let V be a subspace of E.
-
1. A subspace W of E is called an orthogonal complement of V, if
-
(a) W is a complement of V, that is, $V+W= E$
and
$V\cap W=\{0\}$
; -
(b) $V \perp _{\textrm {s}} W$
.
-
-
2. Suppose V admits an orthogonal complement W. The orthogonal projection onto V along W is the linear map $P\colon E\longrightarrow V$
satisfying
$P\circ P = P$
and
$\ker (P)=W$
.
As is indicated in the definition, the orthogonal complement may not exist in general. However, if the subspace is spherically complete, then one can always find an orthogonal complement.
Theorem 5.5 (cf. [Reference van Rooij32, Corollary 4.7]).
Let E be a normed space over
$\mathbb{K} $
, and let D be a subspace of E. If D is spherically complete, then there exists an orthogonal complement
$D^{\perp }$
of D.
This theorem is a direct consequence of the following result.
Proposition 5.6. Let E be a normed space over
$\mathbb{K} $
, and let D be a subspace of E. If D is spherically complete, then there exists a continuous linear map
$T\colon E\to D$
such that D is invariant under T and
$\left \lVert T\right \rVert \leq 1$
.
theorem exists_orthProj_of_sphericallyComplete [SphericallyCompleteSpace D] :
∃ T : E →L[𝕜] ↥D, (∀ a ∈ D, T a = a) ∧ ‖T‖ ≤ 1
Proof. This is immediate if one takes
$\mathcal{U} =\{0\}$
and
$\epsilon _0=1$
in Proposition 6.6—a result we will explain in detail in the next section.
Proof of Theorem 5.5.
Let
$D^{\perp }$
be the kernel of T in Proposition 5.6. We claim that
$D^{\perp }$
is an orthogonal complement of D and T is the orthogonal projection onto D along
$D^{\perp }$
.
If
$x\in D\cap D^{\perp }$
, then
$x=T x =0$
. On the other hand, for any
$x\in E$
, one has
$x-T x\in D^{\perp }$
and
$T x\in D$
, thus
$x=(x-T x)+T x\in D+D^{\perp }$
. This shows that
$D^{\perp }$
is a complement of D.
To show that
$D \perp _{\textrm {s}} D^{\perp }$
, let
$x\in D^{\perp }$
and
$y\in D$
. Then one has
which implies by the ultrametric inequality that
$\left \lVert x\right \rVert \leq \left \lVert x-y\right \rVert $
. As a result, one obtains
$\left \lVert x\right \rVert \leq \mathrm {dist}(x,D)$
and consequently
$x\perp _{\textrm {m}} D$
.
It is a common strategy of defining the data required in a proof, followed by the specifications of the said data in Lean formalizations. Specialized to the orthogonal projection and orthogonal complement, we first prove the existence of the continuous linear map T in Proposition 5.6, and then define the orthogonal projection and orthogonal complement via T.
-- The orthogonal projection
def orthProj [SphericallyCompleteSpace D] : E →L[𝕜] ↥D :=
(exists_orthProj_of_sphericallyComplete 𝕜 D).choose -- the map $T$ in $Proposition$ $5.6$
-- The orthogonal complement
def orthComp : Submodule 𝕜 E :=(exists_orthProj_of_sphericallyComplete 𝕜 D).choose
and formalize their properties as theorems:
theorem IsOrtho.orthComp : (D ⟂ₛ (orthComp 𝕜 D))
theorem isCompl_orthComp : IsCompl D (orthComp 𝕜 D)
theorem norm_orthProj_le_one : ‖orthProj 𝕜 D‖ ≤ 1
theorem orthProj_id : ∀ a ∈ D, (orthProj 𝕜 D) a = a
5.3 Application: Finite dimensional normed spaces
As an application—seemingly unrelated to the orthogonality at first glance—we prove the following result.
Theorem 5.7. If
$\mathbb{K} $
is spherically complete, then every finite dimensional normed space over
$\mathbb{K} $
is spherically complete.
theorem of_finiteDimensional [FiniteDimensional 𝕜 E] : SphericallyCompleteSpace E
The strategy is a direct induction on the dimension:
-
1. The $0$
-dimensional case is trivial. -
2. The $1$
-dimensional spaces are isometric to the base field, which is spherically complete by assumption.instance instSphericallyCompleteSpaceSpanSingleton [SphericallyCompleteSpace 𝕜] (z : E) : SphericallyCompleteSpace (Submodule.span 𝕜 {z}) -
3. Assume that there exists an n-dimensional spherically complete subspace D of E, where $n <\mathrm {dim}E$
. Since D is a proper subspace, one may pick, by Proposition 5.8, an element
$a\in E$
with
$a\notin D$
and
$a\perp _{\textrm {s}} D$
. -
4. Since D and $[a]$
are both spherically complete, so is their product space
$D\times [a]$
(cf. Proposition 3.4). The orthogonality
$a\perp _{\textrm {s}} D$
makes the isomorphism (a) $$ \begin{align} D\oplus[a]\cong D\times [a] \end{align} $$an isometry (again by Proposition 5.8), so that spherical completeness transfers from $D\times [a]$
to
$D\oplus [a]$
via (2) of Proposition 3.4.
Without
$a\perp _{\textrm {s}} D$
the isomorphism (a) need not be an isometry, and spherical completeness would not transfer. The existence of such an a and the resulting isometry are exactly the following proposition.
Proposition 5.8 (cf. [Reference van Rooij32, p. 57 and Lemma 3.14]).
Let E be a normed space over
$\mathbb{K} $
, and let D be a spherically complete proper subspace of E.
-
1. There exists an element $a_0\in E$
such that
$a_0\notin D$
and
$a_0\perp D$
. -
2. One has the isometric isomorphism $D\times [a_0] \cong D+[a_0]$
.
theorem exists_isMOrtho_vec_of_finrank_lt
[SphericallyCompleteSpace D] (hF : Module.finrank 𝕜 D < Module.finrank 𝕜 E) :
∃ (x : E), x ≠ 0 ∧ (x ⟂ₘ D)
def IsMOrtho.directProdIsoSum (x : E) (hxF : x ⟂ₘ D) :
(Submodule.span 𝕜 {x}) × D≃ₛₗᵢ[RingHom.id 𝕜] (Submodule.span 𝕜 {x}) + D
The isometric isomorphism
$D\times [a_0]\cong D+[a_0]$
in Proposition 5.8 is not free: it hinges on the spherical completeness of D. This is easy to overlook in informal writing, where a single symbol
$\cong $
is used for isomorphisms living in different categories. In the category of vector spaces, a direct sum is always naturally isomorphic to the direct product; but for normed spaces the “same” isomorphism need not be an isometry. Here formalization earns its keep: a strict type system forbids conflating the two
$\cong $
’s and forces one to pin down the category of each.
6 Ultrametric Hahn–Banach theorem
In functional analysis, the Hahn–Banach theorem is a fundamental result about the extension of bounded linear functionals. There are various versions of this theorem in different contexts. One of them is stated as follows.
Theorem 6.1. Every continuous linear functional defined on a vector subspace M of a normed space X over
$\textbf {R}$
or
$\textbf {C}$
has a continuous linear extension F to all of X that satisfies
$\lVert f\rVert =\lVert F\rVert $
.
This is already formalized in Mathlib:
theorem exists_extension_norm_eq
{𝕜 : Type u_1} [NontriviallyNormedField 𝕜] [IsRCLikeNormedField 𝕜]
{E : Type u_2} [SeminormedAddCommGroup E] [NormedSpace 𝕜 E]
(p : Subspace 𝕜 E) (f : StrongDual 𝕜 ↥p) :
∃ (g : StrongDual 𝕜 E), (∀ (x : ↥p), g ↑x = f x) ∧ ‖g‖ = ‖f‖
Remark 6.2. In the above theorem, IsRCLikeNormedField is the typeclass in Mathlib saying that the norm field structure is the same as
$\textbf {R}$
or
$\textbf {C}$
, and StrongDual is the space of continuous linear functionals on M.
Unfortunately, this result does not hold if one simply replaces the base field
$\textbf {R}$
or
$\textbf {C}$
by an ultrametric normed field. Instead, one has to take spherical completeness into account.
Theorem 6.3 (cf. [Reference van Rooij32, Theorem 4.8]).
Let
$E,F$
be two normed spaces over
$\mathbb{K} $
, and let D be a subspace of E. If D is spherically complete or F is spherically complete, then every
$f\in \mathcal{L} (D,F)$
can be extended to some
$F\in \mathcal{L} (E,F)$
such that
$\lVert F\rVert =\lVert f\rVert $
.
Instead of formalizing this theorem as two individual theorems in Lean, corresponding to the conditions SphericallyCompleteSpace D and SphericallyCompleteSpace F respectively, we introduce the following concept.
Definition 6.4. The data
$(D,F)$
are called a Hahn–Banach pair if for every
$f\in \mathcal{L} (D,F)$
, there exists an extension
$F\in \mathcal{L} (E,F)$
of f such that
$\lVert F\rVert =\lVert f\rVert $
.
class IsHahnBanachPair [IsUltrametricDist E] [IsUltrametricDist F] : Prop where
is_hb : ∀ f : D →L[𝕜] F, ∃ f' : E →L[𝕜] F,
(∀ v : E, (hv : v ∈ D) → f' v = f ⟨v, hv⟩) ∧ ‖f'‖ = ‖f‖
We provide two instances to show that IsHahnBanachPair holds when either D or F is spherically complete, and this is where the proof of Theorem 6.3 is actually formalized in Lean:
instance instIsHahnBanachPairOfDomainSphericalComplete [SphericallyCompleteSpace D] :
IsHahnBanachPair D F
instance instIsHahnBanachPairOfCodomainSphericalComplete
[SphericallyCompleteSpace F] : IsHahnBanachPair D F
The statement of Theorem 6.3 then immediately follows from the definition of IsHahnBanachPair.
theorem hahn_banach [IsHahnBanachPair D F] (f : D →L[𝕜] F) :
∃ f' : E →L[𝕜] F, (∀ v : E, (hv : v ∈ D) → f' v = f ⟨v, hv⟩) ∧ ‖f'‖ = ‖f‖ :=
IsHahnBanachPair.is_hb f
Remark 6.5. A normed space F over
$\mathbb{K} $
is called injective if
$(D,F)$
is a Hahn–Banach pair for any normed space E and any subspace D of E. Ingleton proved in 1952 that a normed space F is injective if and only if F is spherically complete (cf. [Reference Ingleton14, Theorem 2]), which implies Theorem 6.3 in the case of a spherically complete codomain F. For the case of a spherically complete domain D, we were unable to locate the first appearance of this result in the literature. The author learned this result from van Rooij’s book [Reference van Rooij32, Theorem 4.8].
The proof of Theorem 6.3 heavily relies on the following key result.
Proposition 6.6 (cf. [Reference van Rooij32, Lemma 4.4]).
Let
$E,F$
be two normed spaces over
$\mathbb{K} $
, with F spherically complete. Let D be a subspace of E,
$S\in \mathcal{L} (D,F)$
. Let
$\mathcal{U} $
be a non-empty subset of
$\mathcal{L} (E,F)$
and for each
$U\in \mathcal{U} $
, let
$\epsilon _U>0$
be so that
Then S has an extension
$\overline {S}\in \mathcal{L} (E,F)$
such that
$\lVert \overline {S}-U\rVert \leq \epsilon _U$
for every
$U\in \mathcal{U} $
.
theorem exists_extension_opNorm_le (S : D →L[𝕜] F)
{𝒰 : Set (E →L[𝕜] F)} (h𝒰 : 𝒰.Nonempty)
(ε : ↑𝒰 → ℝ) (hε1 : ∀ T : ↑𝒰, 0 < ε T)
(hε2 : ∀ U V : ↑𝒰, ‖U.val - V.val‖ ≤ max (ε U) (ε V))
(hε3 : ∀ U : ↑𝒰, ∀ x : D, ‖S x - U.val x‖ ≤ ε U * ‖x‖) :
∃ (T : E →L[𝕜] F), (∀ x : D, T x = S x) ∧ (∀ U : ↑𝒰, ‖T - U.val‖ ≤ ε U)
Proof of Theorem 6.3.
When the codomain F is spherically complete, take
$\mathcal{U} =\{0\}$
and
$\epsilon _0=\lVert S\rVert $
in Proposition 6.6 and the resulting map
$\overline {S}$
is the desired extension.
When D is spherically complete, the composition
$S\circ T$
gives the extension, where T is the orthogonal projection onto D along
$D^\perp $
.
As this proof is simple, we skip the formalization details here and focus on the formalization of Proposition 6.6 in the following sections. In particular, in the rest of this section, the meaning of variables S, 𝒰, ε, hε1, hε2, and hε3 will keep the same as in exists_extension_opNorm_le, and their declaration will be omitted for simplicity.
6.1 Reduce to the case of codimension 1
In the proof of [Reference van Rooij32, Lemma 4.4], van Rooij writes:
By a standard application of Zorn’s lemma we may assume that there exists an
$a\in E$
,
$a\notin D$
such that
$E=D+[a]$
.
To translate this assertion into a formalized proof, we need to clarify the partially ordered set
$\mathfrak{P} $
we are working with. In this context,
$\mathfrak{P} $
consists of the pairs
$(M,T)$
, where M is a submodule of E and
$T\in \mathcal{L} (M,K)$
is a continuous linear map, satisfying the following conditions:
-
1. for any $x\in D$
,
$T x = S x$
; -
2. for any $x\in M$
and
$U\in \mathcal{U} $
,
$\lVert T x - U x\rVert \leq \epsilon _U\lVert x\rVert $
; -
3. $(M_1,T_1)\leq (M_2,T_2)$
if
$M_1\subseteq M_2$
and
$T_2$
extends
$T_1$
.
In our project, this set
$\mathfrak{P} $
is formalized as a structure:
structure PartialExtension where
M : Submodule 𝕜 E
hDM : D ≤ M -- D is a submodule of M
T : M →L[𝕜] F
hT : ∀ x : D, T ⟨x, hDM x.prop⟩ = S x -- Condition 1
hU : ∀ U : ↑𝒰, ∀ x : M, ‖T x- U.val x‖ ≤ (ε U) * ‖x‖ -- Condition 2
And we formalize the partial order on
$\mathfrak{P} $
as an instance:
instance instPartialOrderPartialExtension : -- Condition 3
PartialOrder (PartialExtension 𝕜 E F S 𝒰 h𝒰 ε) where
le a b := ∃ hab : a.M ≤ b.M , ∀ x : a.M, b.T ⟨x.val, hab x.prop⟩ = a.T x
... -- Proof of reflexivity, antisymmetry and transitivity. Omitted.
To apply Zorn’s lemma, we need to show that every chain
$\{(M_\alpha ,T_\alpha )\}_{\alpha \in I} \subseteq \mathfrak{P} $
has an upper bound. It is easy to verify that if one takes
$M_{\max }$
to be the union of all the
$M_\alpha $
’s, then
$M_{\max }$
is still a submodule of E, and the
$T_\alpha $
’s can be glued together to form a linear map
$T_{\max }\in \mathcal{L} (M_{\max },F)$
. Moreover, we have the following lemma.
Lemma 6.7. The linear map
$T_{\max }$
is continuous. In particular,
$(M_{\max },T_{\max })$
is an upper bound of the chain
$\{(M_\alpha ,T_\alpha )\}_{\alpha \in I}$
.
Proof. Take an arbitrary
$U\in \mathcal{U} $
and set
$C\mathrel {\mathop :}= \max \{\epsilon _U,\lVert U\rVert \}$
. For any
${x\in M_{\max }}$
, there exists some
$\alpha \in I$
such that
$x\in M_\alpha $
. One computes that
This shows that
$T_{\max }$
is bounded, hence continuous.
When formalizing the fact that
$T_{\max }$
is linear and continuous, the locally-defined nature of
$T_{\max }$
forces us to repeatedly use Classical.choose_spec and the fact that chains are directed in the formalized proof, which makes the code quite verbose and less transparent. Notwithstanding these challenges, we successfully formalize the existence of upper bounds in our project:
lemma bddAbove_of_chain_of_partial_extension
(P : Set (PartialExtension 𝕜 E F S 𝒰 h𝒰 ε))
(hP : IsChain (fun x1 x2 ↦ x1 ≤ x2) P) (hhP : P.Nonempty) : BddAbove P
By applying Zorn’s lemma, we obtain a maximal element
$(M_{\max },T_{\max })$
in
$\mathfrak{P} $
. This reduces the proof of Theorem 6.3 to the case where E is of codimension 1 over D.
Lemma 6.8. If Theorem 6.3 holds when
$E=D+[a]$
for some
$a\in E\backslash D$
, then it holds in general.
Proof. We claim that
$M_{\max }=E$
. If not, take
$a\in E\backslash M_{\max }$
, and set
$M'\mathrel {\mathop :}= M_{\max }+[a]$
. By assumption, there exists some
$T'\in \mathcal{L} (M',F)$
extending
$T_{\max }$
such that for any
$U\in \mathcal{U} $
and
$x\in M'$
,
$\lVert T'x - U x\rVert \leq \epsilon _U\lVert x\rVert $
. This shows that
$(M',T')\in \mathfrak{P} $
and
$(M_{\max },T_{\max })<(M',T')$
, contradicting the maximality of
$(M_{\max },T_{\max })$
.
The corresponding formalized proof of this lemma is integrated in the proof of Proposition 6.6, which we omit here for brevity.
6.2 Remarks on the codimension 1 case
Now we assume that there exists some
$a\in E\backslash D$
such that
$E=D+[a]$
.
It is shown in [Reference van Rooij32] that the spherical completeness of F implies the existence of an element
$z_0\in F$
such that
holds for every
$U\in \mathcal{U} $
and
$x\in D$
.
lemma exists_extensionValue_norm_le [SphericallyCompleteSpace F]
{a : E} (ha1 : a ∉ D) :
∃ z0 : F, ∀ (x : ↥D) (U : ↑𝒰), ‖S x + z0 - U.val (↑x + a)‖ ≤ ε U * ‖↑x + a‖
Then the desired extension is given by
def codimOneExtension [SphericallyCompleteSpace F] {a : E} (ha1 : a ∉ D) :
(D + Submodule.span 𝕜 {a}) → F := fun M => by
have := Submodule.mem_sup.1 M.prop -- $M = x + y$ with $x \in D$ and $y\in [a]$
let lambda := (Submodule.mem_span_singleton.1
this.choose_spec.2.choose_spec.1).choose -- There exists $\lambda\in\ $𝕜 such that $y = \lambda\cdot a$
use S ⟨this.choose, this.choose_spec.1⟩ +
lambda • (exists_extensionValue_norm_le ha1 S h𝒰 hε1 hε2 hε3).choose
Remark 6.9. In the above code snippet, for any
$M\in D+[a]$
, the corresponding
$x\in D$
and
$\lambda \in K$
are obtained by applying Classical.choose_spec and Classical.choose in a mixed manner. This makes it hard to reason about the properties of this map. One potential remedy is to introduce local notations for the required data during the proof. This makes the code more readable, at the cost of a longer preamble (which is not a problem on most occasions).
We prove that
$\overline {S}$
is continuous and linear by showing that it is a bounded linear map:
def isBoundedLinearMap_codimOneExtension [SphericallyCompleteSpace F]
{a : E} (ha1 : a ∉ D) :
IsBoundedLinearMap 𝕜 (codimOneExtension ha1 S h𝒰 hε1 hε2 hε3)
The structure ContinuousLinearMap can then be obtained by IsBoundedLinearMap.toContinuousLinearMap .
6.3 Application: Spherical completeness of
$\mathcal{L} (E,F)$
Besides its use in constructing the orthogonal complement (cf. Proposition 5.6) and proving the ultrametric Hahn–Banach theorem (Theorem 6.3), Proposition 6.6 can also be applied to show the spherical completeness of the space of continuous linear maps to a spherically complete codomain.
Theorem 6.10 (cf. [Reference van Rooij32, Corollary 4.5]).
Let
$E,F$
be two ultrametric normed spaces over an ultrametric normed field K. If F is spherically complete, then so is
$\mathcal{L} (E,F)$
.
The proof of Theorem 6.10 in [Reference van Rooij32] is concise:
Let
$B(T_1,\epsilon _1)\supset B(T_2,\epsilon _2)\supset \cdots $
be balls in
$\mathcal{L} (E,F)$
. Apply Proposition 6.6, taking
$D=\{0\}$
,
$\mathcal{U} =\{T_n\colon n\in \textbf {N}\}$
,
$\epsilon _{T_n}=\epsilon _n$
.
During the formalization, we recognized that there are extra details that need to be taken care of:
-
1. To apply Proposition 6.6, one has to verify that $\epsilon _U>0$
for every
$U\in \mathcal{U} $
in the current context. To do so, the extra condition that the radii of these balls are strictly decreasing is required. By Theorem 3.3, this extra condition does not incur any loss of generality. -
2. The second point is more serious. The declaration “ $\epsilon _{T_n}=\epsilon _n$
” implicitly uses the composition $$ \begin{align*}\mathcal{U}\longrightarrow \textbf{N}\longrightarrow \textbf{R},\ T_n\longmapsto n\longmapsto \epsilon_n,\end{align*} $$which is not well-defined in general, as the map $n\longmapsto T_n$
may not be injective. To bypass this issue, we consider the condition: (a) $$ \begin{align} {\textbf{for any }n\in\textbf{N}\textbf{, there exists }N\in\textbf{N}\textbf{ such that for any }i>N\textbf{, }T_n\neq T_i,} \end{align} $$or, equivalently, any element of $\mathcal{U} $
only appears finitely many times in the sequence
$\{T_n\}_{n\in \textbf {N}}$
.
If this condition holds, then one can take a subsequence $\{T_{n_k}\}_{k\in \textbf {N}}$
of
$\{T_n\}_{n\in \textbf {N}}$
such that the map
$k\longmapsto T_{n_k}$
is injective.theorem exists_injective_subseq_of_finite_duplication {α : Type*} (seq : ℕ → α) (hseq : ∀ n : ℕ, ∃ N, ∀ i > N, seq n ≠ seq i) : ∃ φ : ℕ → ℕ, StrictMono φ ∧ Function.Injective (seq ∘ φ)Then van Rooij’s original argument can be applied to the balls $\{B(T_{n_k},\epsilon _{n_k})\}_{k\in \textbf {N}}$
, which yields a desired element in the intersection of all the
$B(T_{n_k},\epsilon _{n_k})$
and consequently of all the
$B(T_n,\epsilon _n)$
.Conversely, if (a) does not hold, then there exists some $T\in \mathcal{U} $
such that
$T=T_n$
for infinitely many n. Then T itself witnesses the non-emptiness of the intersection of all the
$B(T_n,\epsilon _n)$
.
This kind of subtlety can easily be overlooked in traditional mathematical writing, but has to be addressed carefully in a formalized proof. In our project, we successfully formalize the proof of Theorem 6.10 as an instance by taking these details into account.
7 Spherical completion
The completion of a metric space can be characterized via the following nice universal property.
Theorem 7.1 (cf. [Reference Bourbaki6, Chapter II, Section 3.8, Proposition 16]).
Let
$(X,d)$
be a metric space. The completion of X is a complete metric space
$\widehat {X}$
together with an isometric embedding
$i\colon X\to \widehat {X}$
such that for any complete metric space Y and any uniformly continuous map
$f\colon X\to Y$
, there exists a unique uniformly continuous map
$\widehat {f}\colon \widehat {X}\to Y$
such that
$\widehat {f}\circ i=f$
.
Moreover, the completion can be constructed in a very explicit way, for example, as the space of all Cauchy sequences on X modulo the relation of being “infinitesimally close.”
Unfortunately, there is no canonical way to construct such a “spherical completion” for an arbitrary metric space. On the other hand, for ultrametric normed vector spaces, van Rooij formulated the following concept.
Definition 7.2 (cf. [Reference van Rooij32, p. 146]).
Let E be a normed space over
$\mathbb{K} $
. A spherical completion of E is a spherically complete normed space F over
$\mathbb{K} $
together with an isometric linear embedding
$i\colon E\to F$
such that F has no proper spherically complete subspace containing
$i(E)$
.
This is designed as a class in our project:
class IsSphericalCompletion (ι : E →ₗᵢ[𝕜] F) : Prop
extends SphericallyCompleteSpace F where
minimal_of_sphericallyComplete :
∀ D : Submodule 𝕜 F, SphericallyCompleteSpace D → ι.range ≤ D → D = ⊤
The main goal of this section is to formalize the existence and uniqueness of spherical completions, and to establish several of their properties. The following result of Fleischer is of particular importance.
Theorem 7.3 (cf. [Reference Fleischer11], [Reference van Rooij32, Theorem 4.43]).
Every normed vector space over an ultrametric normed field admits a spherical completion. Any two spherical completions of a normed vector space are isometrically isomorphic.
This is formalized as two separate theorems in our project, one for existence and the other for uniqueness:
theorem exists_isSphericalCompletion : ∃ E₀ : Type u,
∃ _ : NormedAddCommGroup E₀, ∃ _ : NormedSpace 𝕜 E₀, ∃ _ : IsUltrametricDist E₀,
∃ ι : E →ₗᵢ[𝕜] E₀, IsSphericalCompletion ι
theorem IsSphericalCompletion.unique
{F₁ : Type*} [NormedAddCommGroup F₁] [NormedSpace 𝕜 F₁] [IsUltrametricDist F₁]
{F₂ : Type*} [NormedAddCommGroup F₂] [NormedSpace 𝕜 F₂] [IsUltrametricDist F₂]
{ι₁ : E →ₗᵢ[𝕜] F₁} {ι₂ : E →ₗᵢ[𝕜] F₂} :
IsSphericalCompletion ι₁ → IsSphericalCompletion ι₂ →
∃ f : F₁ ≃ₗᵢ[𝕜] F₂, f.toLinearIsometry.comp ι₁ = ι₂
Remark 7.4. Our formalized code proves the existence of the spherical completion in the same universe level u as the original space E. This is a reasonable constraint, as the spherical completion is constructed as a subspace of a certain subquotient of a countable product of E (cf. Proposition 7.12), which is still at the same universe level as E.
Remark 7.5. The spherical completion does not admit as good a universal property as the usual completion of metric spaces: for two spherical completions
$(\breve {E_1},i_1)$
and
$(\breve {E_2},i_2)$
of E, the isometric isomorphism
$\breve {E_1}\cong \breve {E_2}$
is not necessarily unique (see also Corollary 7.14).
7.1 Immediate extensions
The concept of immediate extensions is closely related to the spherical completeness of ultrametric normed spaces, and plays a key role in the proof of Theorem 7.3. In [Reference van Rooij32], van Rooij defines immediate extensions as follows.
Definition 7.6. Let E be a normed space over
$\mathbb{K} $
and let D be a subspace of E. E is called an immediate extension of D if
$0$
is the only element of E that is orthogonal to D.
As an experiment, we tried to formalize this definition using Claude Opus, a large language model developed by Anthropic. It gave a literal translation:
def IsImmediateExtension (D : Submodule 𝕜 E) : Prop := ∀ v : E, (v ⟂ₘ D) → v = 0
While this formalization is mathematically correct, it is not a good design choice. One may need to handle two independent immediate extensions
$E_1/D$
,
$E_2/D$
of D in the proof of Theorem 7.3. In this case, if one defines D to be of type Submodule 𝕜 E1
, then an awkward coercion is required to express the condition that
$E_2$
is an immediate extension of D, which makes the code less concise. To resolve this issue, we reformulate Definition 7.6 in the following more flexible way.
Definition 7.7. Let
$E, F$
be normed spaces over
$\mathbb{K} $
. Let
$f\colon E\longrightarrow F$
be an isometric linear map. We say f is immediate if the only element of F that is orthogonal to
$\mathrm {Im}(f)$
is
$0$
.
def IsImmediate (f : E →ₗᵢ[𝕜] F) : Prop := ∀ v : F, (v ⟂ₘ LinearMap.range f) → v = 0
Compared to Definition 7.6, this definition allows E and F to be independent types, which makes the statements of related results more convenient to work with. For example, van Rooij proved the following result, which is crucial for the uniqueness argument in Theorem 7.3.
Lemma 7.8 (cf. [Reference van Rooij32, Lemma 4.42]).
Let F be an immediate extension of a normed space E and let H be any spherically complete normed space containing E. Then
$\mathrm {id}_E$
can be extended to a linear isometry of F into H.
With our new definition, this is restated in our project as follows.
Lemma 7.9. Let
$E, F, H$
be normed spaces over
$\mathbb{K} $
, with H spherically complete. If there exists a linear isometry
$f\colon E\longrightarrow H$
, then it factors through any immediate map
$E\longrightarrow F$
.

theorem IsImmediate.exists_linearIsometry_comp_eq {H : Type*}
[NormedAddCommGroup H] [NormedSpace 𝕜 H] [IsUltrametricDist H]
[SphericallyCompleteSpace H]
(f : E →ₗᵢ[𝕜] F) (hf : IsImmediate f) (g : E →ₗᵢ[𝕜] H) :
∃ (h : F →ₗᵢ[𝕜] H), LinearIsometry.comp (h : F →ₗᵢ[𝕜] H) (f : E →ₗᵢ[𝕜] F) = g
Remark 7.10. This lemma is a quick consequence of the Hahn–Banach theorem (Theorem 6.3). We do not elaborate its formalized proof here, for brevity.
7.2 Maximal immediate extensions: A Zorn’s lemma argument
In [Reference van Rooij32], the spherical completion is constructed via the following result.
Proposition 7.11. Let E be a normed space over
$\mathbb{K} $
, which embeds into some normed space F via a linear isometry
$f\colon E\to F$
. Consider the set S of submodules M of F containing
$\mathrm {Im}(f)$
such that the inclusion map
$\mathrm {Im}(f)\longrightarrow M$
is immediate. Then
-
1. S has a maximal element $\breve {E}$
with respect to inclusion. -
2. If F is spherically complete, then $\breve {E}$
is a spherical completion of E.
The set S is formalized as follows:
def IsImmediate.immediateExtensionSubmodules
(f : E →ₗᵢ[𝕜] F) : Set (Submodule 𝕜 F) :=
{M : Submodule 𝕜 F | ∃ hc : f.range ≤ M,
∀ v : M, (v ⟂ₘ LinearMap.range (Submodule.inclusion hc)) → v = 0 }
After this definition, we apply Zorn’s lemma to show the existence of maximal elements in IsImmediate.immediateExtensionSubmodules. Given a chain C in this set, an upper bound
$M_{\max }$
is given by the union of all elements of C. We verify that
$M_{\max }$
lies in this set by showing that the inclusion map
$\mathrm {Im}(f)\longrightarrow M_{\max }$
is immediate. This yields the formalized proof of the first assertion of Proposition 7.11:
theorem IsImmediate.exists_maximal_immediateExtensionSubmodule (f : E →ₗᵢ[𝕜] F) :
∃ m, Maximal (fun x ↦ x ∈ immediateExtensionSubmodules E F f) m
We define maximalImmediateExtensionEmbedding f to be the inclusion map of E into its maximal immediate extension in F, and prove that it gives a spherical completion of E when F is spherically complete:
instance instIsSphericalCompletionOfMaximalImmediateExtensionSubmodule
[SphericallyCompleteSpace F] (f : E →ₗᵢ[𝕜] F) :
IsSphericalCompletion (maximalImmediateExtensionEmbedding f)
7.3 Existence of spherically complete extension
With Proposition 7.11, the existence of spherical completions of E is reduced to the existence of a spherically complete extension of E. This is guaranteed by the following result.
Proposition 7.12 (cf. [Reference van Rooij32, Theorem 4.1]).
Let E be a normed space over
$\mathbb{K} $
. Let
$\ell ^\infty (E)$
be the space of all bounded
$\textbf {N}$
-indexed E-sequences, equipped with the supremum norm. Let
Then
-
1. $c_0(E)$
is a closed subspace of
$\ell ^\infty (E)$
. In particular,
$\ell ^\infty (E)/c_0(E)$
is a normed space over K. -
2. $\ell ^\infty (E)/c_0(E)$
is spherically complete. -
3. The diagonal embedding $i\colon E\to \ell ^\infty (E)/c_0(E),\ x\mapsto [(x,x,x,\ldots )]$
is an isometric linear embedding.
In particular, every normed space over
$\mathbb{K} $
admits a spherically complete extension.
In Mathlib,
$\ell ^\infty (E)$
is already formalized as lp E ⊤, which is a normed space over K. We formalize the subspace
$c_0(E)$
as follows:
def c₀ (G : ℕ → Type*) [∀ i, NormedAddCommGroup (G i)]
[∀ i, NormedSpace 𝕜 (G i)] : Submodule 𝕜 ↥(lp G ⊤) where
carrier := {f : lp G ⊤ | Tendsto (fun n ↦ ‖f n‖) atTop (𝓝 0)} -- the underlying set
add_mem' := ... -- closedness under addition. Omitted.
zero_mem' := ... -- zero element is in c₀. Omitted.
smul_mem' := ... -- closedness under scalar multiplication. Omitted.
The closedness of
$c_0(E)$
and the resulting spherical completeness of the quotient space are not difficult to verify, and we implement them as two instances.
Finally, the diagonal embedding is formalized as a LinearIsometry:
def lpQuotientEmbedding :
E →ₗᵢ[𝕜] ((lp (fun (_ : ℕ) ↦ E) ⊤)⧸ c₀ 𝕜 (fun (_ : ℕ) ↦ E)) where
toFun x := by
refine (QuotientAddGroup.mk' _) (⟨fun (_ : ℕ) ↦ x, ?_⟩)
... -- Proof of the fact that the diagonal embedding belongs to $\ell^\infty$. Omitted.
... -- map_add', map_smul', norm_map'. Omitted.
7.4 Weak universal properties of the spherical completion
As we mentioned at the beginning of this section, the spherical completion does not enjoy as good a universal property as the usual completion of metric spaces. Still, some weaker universal-property-like results can be established.
To begin with, following van Rooij, we observe that the uniqueness of spherical completions in Fleischer’s theorem (cf. Theorem 7.3) follows from Lemma 7.9: take two spherical completions
$f_1\colon E\longrightarrow F_1$
and
$f_2\colon E\longrightarrow F_2$
of E. Since
$f_1$
is immediate and
$F_2$
is spherically complete, Lemma 7.9 gives an isometric linear map
$g\colon F_1\longrightarrow F_2$
such that
$g\circ f_1=f_2$
. As a result, the image of g is a spherically complete subspace of
$F_2$
, which equals
$F_2$
by the minimality of
$F_2$
. Hence g is surjective, and consequently an isometric isomorphism.
On the other hand, the spherical completion provides another way to describe the spherical completeness of ultrametric normed spaces.
Corollary 7.13. Let E be a normed space over
$\mathbb{K} $
. Then the following are equivalent:
-
1. E is spherically complete.
-
2. The embedding of E into its spherical completion $\breve {E}$
is surjective. -
3. E is maximally complete, that is, there is no non-trivial immediate extension of E.
theorem IsSphericalCompletion.iff_embedding_to_sphericalCompletion_surjective
{ι : E →ₗᵢ[𝕜] F} (hF : IsSphericalCompletion ι) :
SphericallyCompleteSpace E ↔ Function.Surjective ι
theorem iff_maximallyComplete :
SphericallyCompleteSpace E ↔ MaximallyComplete 𝕜 E
The proof is not difficult, and we omit the details here.
Finally, we show that the spherical completion is minimal among all spherically complete extensions of E, which can be viewed as a weaker analogue of Theorem 7.1.
Corollary 7.14. Let
$E,F$
be normed spaces over
$\mathbb{K} $
. Let
$f\colon E\longrightarrow F$
be a linear isometry and let
$\iota \colon E\longrightarrow \breve {E}$
be a spherical completion of E. Then there exists a linear isometry
$T\colon \breve {E}\longrightarrow F$
such that
$T\circ \iota =f$
.
theorem IsSphericalCompletion.weak_universal_property
{F' : Type*} [NormedAddCommGroup F'] [NormedSpace 𝕜 F'] [IsUltrametricDist F']
[SphericallyCompleteSpace F'] (f : E →ₗᵢ[𝕜] F')
{ι : E →ₗᵢ[𝕜] F} (hF : IsSphericalCompletion ι) :
∃ T : F →ₗᵢ[𝕜] F', T.comp ι = f
Data availability statement
The GitHub repository for this project (https://github.com/YijunYuan/SphericalCompleteness) provides two branches: master, which contains the latest development version, and paper, which preserves the exact code used in this article for reproducibility.
Every code snippet highlighted with a colored background in this article links directly to its corresponding implementation in the article branch of the GitHub repository. URL of code: https://github.com/YijunYuan/SphericalCompleteness/tree/paper
Acknowledgments
The author would like to thank Jiedong Jiang for helpful suggestions on the design of the formalization, and the anonymous referees for their careful reading of the manuscript and their valuable comments, which significantly improved the quality of this article and the formalized code.
Funding statement
The research is partially supported by the National Key R&D Program of China (Grant No. 2024YFA1014000).
Declaration of AI usage
The author used GPT 5.3 from OpenAI and Claude Opus 4.8 from Anthropic in this work in the following aspects:
-
1. The docstrings of the Lean code are partially generated by GPT-5.3 and Claude Opus 4.8, which we fed with Mathlib’s official guideline for documentation style as part of the prompt.
-
2. Although all the code in the initial version is completely human-written, we used Claude Opus 4.8 to simplify the code and to provide suggestions for refactoring. Mathlib’s official guidelines for naming conventions and code style were also provided as part of the prompt.
The author takes full responsibility for the correctness of the code and the content of this article.
