Ekeland's variational principle in weak and strong systems of arithmetic

We analyze Ekeland's variational principle in the context of reverse mathematics. We find that that the full variational principle is equivalent to $\Pi^1_1$-${\sf CA}_0$, a strong theory of second-order arithmetic, while natural restrictions (e.g.~to compact spaces or continuous functions) yield statements equivalent to weak K\"onig's lemma (${\sf WKL}_0$) and to arithmetical comprehension (${\sf ACA}_0$). We also find that the localized version of Ekeland's variational principle is equivalent to $\Pi^1_1$-${\sf CA}_0$ even when restricting to continuous functions. This is a rare example of a statement about continuous functions having great logical strength.


Introduction
The field of reverse mathematics, introduced by H. Friedman [10], aims to identify the minimal foundational assumptions required to prove specific results from several mathematical fields including mathematical analysis. There are many advantages to determining these minimal assumptions, among them aiding in extracting computational content from theorems whose original proofs were non-constructive. It is also desirable from a methodological perspective to avoid strong set-theoretic assumptions when possible, and indeed advances in reverse mathematics have shown us that a large portion of known mathematics can be carried out within a relatively small fragment of second-order arithmetic [13]. Second-order arithmetic extends the language of Peano arithmetic by adding variables and quantifiers ranging over sets of natural numbers (see §2); this is sufficient to formalize many familiar concepts from analysis, including real numbers (and, more generally, points in a complete separable metric space, also called a Polish space), continuous functions, and open and closed sets (see §3). One can then ask which axioms are needed to prove (say) the Stone-Weierstrass theorem in this framework.
Although there are many exceptions, a surprisingly large portion of the theorems analyzed are equivalent to one of a handful of systems of second-order arithmetic. These axiomatic systems are always assumed to extend the 'base theory' of reverse mathematics, recursive comprehension (RCA 0 ), and the ones we consider are weak König's lemma (WKL 0 ), arithmetical comprehension (ACA 0 ), and Π 1 1 -comprehension (Π 1 1 -CA 0 ), listed in strictly increasing order of strength. Each of RCA 0 , ACA 0 and Π 1 1 -CA 0 include axioms asserting that sets of the form {n ∈ N : ϕ(n)} exist, where in the case of RCA 0 , ϕ must express a computable predicate; in the case of ACA 0 , ϕ may contain arbitrary quantifiers over natural numbers (but not over sets of natural numbers); and in the case of Π 1 1 -CA 0 , ϕ is of the form ∀Xψ(n, X), where X is a second-order variable and ψ(n, X) contains no additional second-order quantifiers. Meanwhile, the theory WKL 0 asserts that any infinite binary tree has an infinite branch.
It is known, for example, that the Baire category theorem is provable in RCA 0 , that the Heine-Borel theorem is equivalent to WKL 0 , and that the Stone-Weierstrass theorem is equivalent to ACA 0 . As we will see throughout the text, there are many more examples of theorems equivalent to these theories. On the other hand, statements equivalent to Π 1 1 -CA 0 are a bit more difficult to come by. One example is the Cantor-Bendixson theorem, stating that any closed subset of a Polish Date: February 12, 2019. space can be written as the union of a countable set and a perfect set (see [13] for analyses of the Heine-Borel, Stone-Weierstrass, and Cantor-Bendixson theorems).
Our goal in this article is to study Ekeland's variational principle [5] in the context of reverse mathematics. This principle states that under certain conditions, lower semi-continuous functions on complete metric spaces always attain 'approximate minima,' which we call critical points. In his original paper [5] and the survey [6], Ekeland provides many applications of his variational principle, centered around optimization problems concerning minimal surfaces, partial differential equations, geodesics, the geometry of Banach spaces, control theory, and more. Ekeland's variational principle has been studied extensively, leading to many variants and extensions (see e.g. [1,11]). The variational principle can also be used to give an easy proof of Caristi's fixed point theorem [3], whose logical strength we analyze in forthcoming work [7][8][9].
A priori, an analysis of Ekeland's variational principle in reverse mathematics is a natural and interesting project. Ekeland's variational principle is a well-known and important result, and understanding its computational content could lead to algorithms for approximating critical points, or at least determining that no such algorithm exists. From a technical perspective, lower semicontinuous functions have not yet received much attention in reverse mathematics, and developing a theory of these functions in second-order arithmetic is an interesting endeavor on its own (see §4).
However, a posteriori the analysis of Ekeland's variational principle is even more interesting and quite surprising: as we will see, natural restrictions of the result (e.g. to compact spaces, to continuous f ) yield statements equivalent over RCA 0 to each of WKL 0 , ACA 0 , and Π 1 1 -CA 0 , including what is, to the best of our knowledge, the first statement about continuous functions stemming from analysis that is equivalent to Π 1 1 -CA 0 . Before diving into formal systems, let us discuss the variational principle in more detail and sketch a proof. Let R = R ∪ {±∞}, where we stipulate that sup ∅ = −∞ and inf ∅ = ∞. If X is a metric space, recall that a function f : X → R is lower semi-continuous if for every x ∈ X and every λ < f (x), there is a δ > 0 such that whenever d(x, y) < δ, it follows that f (y) > λ. The notion of an upper semi-continuous function is defined dually. Clearly, a function that is both upper and lower semi-continuous is continuous. Additionally, recall the following well-known characterization of semi-continuity. If f : X → R ≥0 is continuous but X is not compact, then f may not attain its infimum, and since every continuous function is also lower semi-continuous, the same holds of lower semi-continuous functions. Nevertheless, Ekeland's variational principle states that f has points that are in a sense approximate local minima, and we call these points ε-critical points. For the sake of brevity, we will often refer to lower semi-continuous functions f : X → R ≥0 as potentials.
Ekeland's variational principle then reads as follows. Theorem 1.3 (Ekeland [5]). If X is a complete metric space and f : X → R ≥0 is any potential, then for every ε > 0, f has an ε-critical point x * .
Moreover, for any x 0 ∈ X , we can choose x * so that In the literature, it is often assumed that f (x 0 ) ≤ ε + inf(f ), in which case (1) is replaced by d(x 0 , x * ) ≤ 1. We refer to Theorem 1.3 without (1) as the free variational principle (FVP) and with (1) as the localized variational principle (LVP); note that Ekeland instead calls these the weak and strong principles, respectively.
Let us sketch a proof similar to that presented by Du [4] based on one given by Brézis and Browder [2] in a more general order-theoretic setting. Suppose that X is a complete metric space, let x 0 ∈ X , and let f : X → R ≥0 be any potential. For ε > 0, define a partial order ε on X given by y ε x if and only if f (y) ≤ f (x)−εd(x, y). For x ∈ X , define S(x) = {y ∈ X : y ε x}. Then we construct a sequence (x n : n < ω) by letting x n+1 ∈ S(x n ) be such that f (x n ) < inf f [S(x n )] + 2 −n . It is not too hard to check that (x n : n < ω) is Cauchy and hence converges to some x * ∈ X , and, using the fact that f is lower semi-continuous, that f (x * ) ≤ f (x n ) for all n < ω. From this it readily follows that x * is ε-critical and satisfies (1); we leave the details to the reader.
As it turns out, there are some issues when attempting to formalize this argument in second-order arithmetic. The sets S(x n ) are closed, and finding infima of lower semi-continuous functions on closed sets requires Π 1 1 -CA 0 in general. It is easier to formalize the argument when S(x n ) is open and f is continuous, and we can achieve this by replacing S(x n ) by a suitable open set. However, this modification typically causes (1) to fail. In fact, we obtain that the FVP for continuous functions is equivalent to ACA 0 ( §7), while the LVP is equivalent to Π 1 1 -CA 0 , even when f is assumed to be continuous ( §10). This last result is particularly interesting because it gives an example of a statement about continuous functions that is equivalent to Π 1 1 -CA 0 . Typically the mathematics of continuous functions can be carried out in ACA 0 and below.
By tweaking other parameters in the statement, for example taking X to be compact or even to be a specific space such as the unit interval, we obtain several variants of the variational principle, each equivalent to one of WKL 0 , ACA 0 or Π 1 1 -CA 0 . The equivalence between these theories and variational principles is established over RCA 0 , and hinges on known equivalences, e.g. the equivalence between ACA 0 and the fact that every increasing sequence of rationals bounded above has a supremum. The main reversals are found in §9. A full summary of our main results is found in §11.

Subsystems of second-order arithmetic
In this section we review the subsystems of second-order arithmetic we will be working with, loosely following the presentation of Simpson [13]. Let us first settle conventions regarding syntax. The language of second-order arithmetic consists of first-order variables intended to range over natural numbers; second-order variables intended to range over sets of natural numbers; constant symbols 0 and 1; 2-ary function symbols + and ×; and 2-ary relation symbols =, <, and ∈. Terms and formulas are built from variables, constant symbols, function symbols, relation symbols, propositional connectives (¬, ∧, ∨, etc.), and the quantifiers ∀ and ∃. The equality relation symbol is restricted to first-order objects. Equality for second-order objects is defined via ∈, and we write X = Y as an abbreviation for ∀n(n ∈ X ↔ n ∈ Y ). Similarly, we write X ⊆ Y as an abbreviation for ∀n(n ∈ X → n ∈ Y ).
We use ∆ 0 0 to denote the class of all formulas, possibly with parameters, where no second-order quantifiers appear and all first-order quantifiers are bounded; that is, of the form ∀x(x < t → ϕ) or ∃x(x < t ∧ ϕ). We simultaneously define Σ 0 0 = Π 0 0 = ∆ 0 0 , and we recursively define Σ 0 n+1 to be the set of all formulas of the form ∃xϕ with ϕ ∈ Π 0 n and similarly define Π 0 n+1 to be the set of all formulas of the form ∀xϕ with ϕ ∈ Σ 0 n . We denote by Π 0 ω the union of all Π 0 n ; these are the arithmetical formulas. The classes Σ 1 n and Π 1 n are defined analogously by counting alternations of second-order quantifiers and setting Σ 1 0 = Π 1 0 = ∆ 1 0 = Π 0 ω . We use Robinson arithmetic Q as our background theory, which essentially consists of the axioms of PA without induction (see [12,Definition I.1.1]). When added to the basic axioms of Q, the following schemes axiomatize many of the theories we consider. Below, Γ denotes a class of formulas.
• Γ-CA : ∃X∀x x ∈ X ↔ ϕ(x) , where ϕ ∈ Γ and X is not free in ϕ; Recursive comprehension, the base theory of second-order arithmetic, is defined as We also define the theory of arithmetical comprehension ACA 0 : RCA 0 + Σ 0 1 -CA and the much stronger theory Π 1 1 -CA 0 : ACA 0 + Π 1 1 -CA. This gives us three of the four important theories that we consider; the fourth, WKL 0 , requires formalizing trees in second-order arithmetic.
RCA 0 suffices to define a bijective pairing function ·, · : N 2 → N that is increasing in both coordinates, such as x, y = (x + y) 2 + x. We also use ·, · to denote a pairing function on sets, which may also be defined in a standard way. With this, a binary relation is a pair of sets A, R with A, R ⊆ N, where the elements of R are of the form n, m with n, m ∈ A. When a binary relation F is meant to represent a function, we write y = F (x) instead of x, y ∈ F . RCA 0 also suffices to implement the typical codings of finite sequences of natural numbers as natural numbers (see [13,Section II.2], for example). The set of all finite sequences of natural numbers is denoted N <N . We write σ ⊑ τ if σ is an initial segment of τ , σ ⊏ τ if σ is a proper initial segment of τ , and define ↓ σ = {τ ∈ N <N : τ ⊑ σ}. If x : N → N and n ∈ N, we write x ↾ n for the finite sequence (x(i)) i<n . We extend the use of ⊏ by writing σ ⊏ x whenever σ = x ↾ n for some n.
that is, if all entries appearing in elements of T are either 0 or 1. When T ⊆ N <N is a tree, we say that an infinite sequence x is a path through T if ∀n(x ↾ n ∈ T ). The collection of all paths through T is denoted [T ].
Say that a set X ⊆ N is finite if it is bounded above, and say that X is infinite otherwise. With this, we define the axiom WKL to be the natural formalization of the following theorem.
For reference, we list the theories we have defined in increasing order of strength: The standard reference for second-order arithmetic is Simpson's [13], and we refer the reader to it for a complete treatment of all the material mentioned above.

Metric spaces in second-order arithmetic
Part of the appeal of second-order arithmetic as a foundational system for mathematics is that it suffices to develop a large part of mathematical analysis, particularly when dealing with complete separable metric spaces. However, this requires some coding machinery. In this section, we review this machinery and establish notation that will be used throughout.
First, we assume that Q is represented in some standard way using e.g. pairs of natural numbers and that R is represented by rapidly converging Cauchy sequences of rationals as in [13,Section II.4]. We use the notation Q >0 = {q ∈ Q : q > 0}, and we define Q ≥0 , R ≥0 , etc. analogously. Definition 3.1 (RCA 0 ; see [13, Definition II.5.1]). A (code for a) complete separable metric space X = X is a nonempty set X ⊆ N together with a sequence of real numbers d : We write x ∈ X to mean that x is a point of X. We identify a ∈ X with a sequence (a) i∈N and consider X as a dense subset of X. We set d(x, y) = lim n→∞ d(x n , y n ), and write x = X y if d(x, y) = 0 (subscripts will be omitted if there is no confusion).
We use either notation X or X to denote complete separable metric spaces. The symbol X emphasizes that the space is coded by the dense set X (and the metric on X). The following spaces appear throughout.
(1) The real line, R, with dense set the rational numbers, Q, equipped with the usual metric.
Closed subintervals of R may be represented similarly, where the dense set for In the cases of the Baire space and the Cantor space, a sequence that is eventually zero may be represented via an appropriate finite initial segment and hence as a natural number. If σ is a finite sequence, then where convenient we identify σ with σ 0 N , which is the infinite sequence beginning with σ and is then identically zero. We remark also that the official dense set for C [a, b] in [13] is the set of polynomial functions f : [a, b] → Q with rational coefficients, but piecewise linear functions are more convenient for us. The two presentations are equivalent over RCA 0 (see [  . Let X be a complete separable metric space. A (code for a) rational open ball B r (a) is an ordered pair a, r , with a ∈ X and r ∈ Q >0 . We define B r (a) B q (b) if d(a, b) + r ≤ q, and we define B r (a) B q (b) if d(a, b) + r < q.
A (code for an) open set U in X is a set U ⊆ N × X × Q >0 , where a point x ∈ X is said to belong to U (abbreviated x ∈ U ) if it satisfies the Σ 0 1 condition ∃n∃a∃r((d(x, a) < r ∧ (n, a, r) ∈ U ). A (code for a) closed set C is the same as a code for its complement X \ C, except we define x ∈ C if x ∈ X \ C. We remark that B r (a) B q (b) implies that B r (a) ⊆ B q (b) (in the usual set-theoretic sense), but not necessarily the converse. To see this, assume that X is a singleton {a 0 }; then {a 0 } = B 2 (a 0 ) ⊆ B 1 (a 0 ), but B 2 (a 0 ) B 1 (a 0 ). Note also that for X ⊆ R, we may represent basic open sets in the form (a − r, a + r) rather than B r (a), and we will often prefer this representation. On occasion we will regard closed balls (or, more precisely, closures of balls) as metric spaces in their own right, in which case if B r (a) is a ball in X, then B r (a) is the subspace with dense set B r (a) ∩ X.
We may also reason about compactness within second-order arithmetic. 1 We We say that X is Heine-Borel compact if for every sequence (B r k (a k ) : k ∈ N) of rational open balls such that (∀x ∈ X )(∃k ∈ N)(x ∈ B r k (a k )), there is an N ∈ N such that (∀x ∈ X )(∃k < N )(x ∈ B r k (a k )).
What we call 'compact' might be more properly called 'uniformly (or effectively) totally bounded,' but when working with complete separable metric spaces in second-order arithmetic, the convention is to use 'compact' for this notion, and we do not wish to deviate. WKL 0 is required to show that every compact (in the above sense) complete separable metric space is Heine-Borel compact. (1) WKL 0 .
(2) Every compact complete separable metric space is Heine-Borel compact.
Sequential compactness is an even stronger notion. ACA 0 is required to show that every compact space is sequentially compact. (1) ACA 0 .
(2) Every infinite sequence of points in a compact complete separable metric space has a convergent subsequence. Note that the equivalence with (5) is not stated explicitly in [13], but it follows from the proof of Theorem III.2.2 given there. We conclude this section by defining continuous functions between complete separable metric spaces. The idea is to code a continuous function f : X → Y by an enumeration of (codes for) pairs of open balls B r (a), B q (b) , where B r (a) ⊆ X and B q (b) ⊆ Y. If the pair B r (a), B q (b) appears in the enumeration, then this means that f maps B r (a) into the closure of B q (b). Definition 3.6 (RCA 0 ; [13, Definition II.6.1]). Let X = X and Y = Y be complete separable metric spaces. A continuous partial function f : X → Y is coded by a set Φ ⊆ N × X × Q >0 × Y × Q >0 that satisfies the properties below. Let us write B r (a) Φ → B s (b) for ∃n (n, a, r, b, s) ∈ Φ . Then, for all a, a ′ ∈ X, all b, b ′ ∈ Y , and all r, r ′ , s, s ′ ∈ Q >0 , Φ must satisfy:  . For a given Σ 0 1 -formula ϕ(x), the following is provable within RCA 0 . Let X = X be a complete separable metric space. If x = X y implies ϕ(x) ↔ ϕ(y), then there exists (a code for) an open set U ⊆ X such that ϕ(x) ↔ x ∈ U .
This lemma guarantees that a Σ 0 1 -definable subset of a complete separable metric space is an open set, and thus a Π 0 1 -definable subset is a closed set. Note that this lemma holds uniformly. In other words, if ϕ(x, i) is a Σ 0 1 -formula that defines a subset of X for each i ∈ N, then there exists a sequence of codes for open sets (U i ) i∈N such that ϕ(x, i) ↔ x ∈ U i . Intuitively, the following lemma states that if a function is uniformly continuous in an effective way and the values of the function can be computed on a dense set (e.g., if f (x) is provided by elementary functions, by power series, etc.), then there is a code for the function. This property also holds restricted to any open set.
Then, there exists (a code for) a continuous function f : Proof. Let U be the code for U . Define a code Φ for a continuous function f : The code Φ exists because the above conditions can be described by a Σ 0 1 -formula. It is easy to see that Φ satisfies (cf2) and (cf3) of Definition 3.6. We show that Φ also satisfies (cf1). Assume , where in each case the second condition is satisfied by n, a i , y i and m, a j , y j , respectively. Without loss of generality, we may assume that n ≤ m and that Finally, we check that U = dom(f ) and f (a i ) = y i . If x / ∈ U , then x / ∈ dom(f ) by the first condition, thus we have dom(f ) ⊆ U . For the converse, assume that x ∈ U and ε > 0. Without loss of generality, ε > 0 can be taken so that Since ε was arbitrary and s < ε, this means that x ∈ dom(f ). If x = a j for some j ∈ N in the above, then i can be always chosen to be equal to j, and thus one can find B r (a) Φ → B s (b) with a j ∈ B r (a), y j ∈ B s (b) and s < ε for all ε > 0. This means that f (a j ) = y j for all j ∈ N.
We also remark that continuous partial functions can be patched together, provided they are mutually compatible. . Let X = X and Y = Y be complete separable metric spaces. Assume that (U i , f i ) i∈N is a sequence of pairs of (codes for) open sets U i ⊆ X and continuous functions f i : U i → Y such that f i (x) = f j (x) for any i, j ∈ N and x ∈ U i ∩ U j . Then, there exists (a code for) a continuous functionf : Notice that the above lemmas also hold uniformly. For Lemma 3.8, if we are given a sequence ( a i,j , y i,j i∈N , U j , h j : j ∈ N), where a i,j , y i,j i∈N , U j and h j satisfy the conditions of Lemma 3.8 for all j ∈ N, then we may obtain a sequence of continuous functions (f j : U j → Y) j∈N .
Finally, we consider products of finitely many metric spaces (X i : i < n). In [13, Example II.5.4], product spaces are defined via the Euclidean metric, but for our purposes it is more convenient to use the 'max' metric instead. Definition 3.10 (RCA 0 ; see [13,Example II.5.4]). Let (X i : i < n) be complete separable metric spaces coded by dense sets (X i : i < n) and metrics (d i : i < n). The product space X = i<n X i is the complete separable metric space coded by the dense set X = i<n X i and the metric d : Products of metric spaces will be very useful to us. For example, we may use them to define Banach spaces in the context of second order arithmetic: these are simply metric spaces X equipped with a designated element 0 ∈ X and total, continuous functions + : X × X → X and · : R × X → X such that if we define x = d(x, 0) then (X , 0, +, ·, · ) satisfies the standard definition of a normed vector space. On occasion will make free use of the fact that some of the spaces we consider, such as C [0, 1] , come equipped with a standard Banach space structure.
If X = i<n X i is the product of the complete separable metric spaces (X i : i < n), then, officially, the basic open sets in X are those of the form B r ( a), where a ∈ i<n X i and r ∈ Q >0 . However, when working with X , it is often more convenient to think of the basic open sets as being the sets of the form is a basic open set in X i . The following lemma says that in RCA 0 we can uniformly translate between the two styles of basic open sets when coding open sets. Therefore we may always use the style of open set that is most convenient. Lemma 3.11 (RCA 0 ). Let (X i : i < n) be complete separable metric spaces coded by dense sets (X i : i < n) and metrics (d i : i < n). Let X = i<n X i and d code X = i<n X i as in Definition 3.10.
(i) There is a function f : f (a 0 , r 0 , . . . , a n−1 , r n−1 , ·) enumerates an official code for the unofficial basic open set given by g( a, r) = (a 0 , r, . . . , a n−1 , r) translates the code a, r for the official basic open set B r ( a) to the code (a 0 , r, . . . , a n−1 , r) for the equivalent unofficial basic open set i<n B r (a i ).

Semi-continuous functions in second-order arithmetic
Although continuous functions have been extensively studied in the context of second-order arithmetic, lower semi-continuous functions have received less attention. Fortunately, they admit a natural representation in the spirit of Definition 3.6. Definition 4.1 (RCA 0 ). Let X = X be a complete separable metric space. A lower semi-continuous partial function f : X → R is coded by a set Ψ ⊆ N × X × Q >0 × Q that satisfies the properties below. Let us write B r (a) Ψ ⇁ q for ∃n((n, a, r, q) ∈ Ψ). Then, for all a, a ′ ∈ X, all q, q ′ ∈ Q, and all r, r ′ ∈ Q >0 , Ψ must satisfy: If b ∈ R is such that for every a ∈ X and r ∈ Q >0 there is m ∈ N such that (m, a, r, b) ∈ Ψ, we say that Φ is a code of a lower semi-continuous function f : X → R ≥b . If b = 0, we call the function coded by Φ a potential.
Suppose that X is a complete separable metric space. As with Definition 3.6, the idea behind Definition 4.1 is that Ψ enumerates pairs B r (a), q with the property that if f is the function being coded by Ψ, then f maps B r (a) ∩ dom(f ) into [q, ∞]. One may define upper semi-continuous partial functions from X to R by appropriately dualizing Definition 4.1, in which case we write B r (a) Ψ ⇀ q for the dual of B r (a) Ψ ⇁ q. We remark that according to our definition we should always have dom(f ) = X , as recalling that sup ∅ = −∞ we see that every subset of R has a supremum in R. However, this fact is not provable in RCA 0 , which is why the notation dom(f ) is relevant.
Next we show that RCA 0 proves a version of Lemma 1.1, which we take as evidence that Definition 4.1 is a reasonable definition of semi-continuity for use in RCA 0 . Indeed, we prove an RCA 0 version of the fact that a function f : X → R is lower semi-continuous if and only if { x, y ∈ X × R : f (x) ≤ y} is closed. (i) If f : X → R is lower semi-continuous and total, then { x, y ∈ X × R : f (x) ≤ y} is closed.
(ii) If C ⊆ X × R is a closed set such that • for every x ∈ X and y, z ∈ R, if x, y ∈ C and z ≥ y, then x, z ∈ C, and • for every x ∈ X , inf{y ∈ R : x, y ∈ C} exists then there is a lower semi-continuous function f : (ii) Let C be a closed set as in the statement of (ii), and let U be the complement of C. Enumerate a code Φ for a lower semi-continuous function f by enumerating B r (a) B s (b) and q < v. We show that, for every x ∈ X , f (x) exists and equals inf{z ∈ R : x, z ∈ C} (which exists by the assumptions on C). So let x ∈ X , and let y = inf{z ∈ R : x, z ∈ C}. We need to show that Suppose that q ∈ Q is such that there is a there is a ball B r (a) ⊆ X with x ∈ B r (a) and From this we can conclude that if z ∈ R is such that x, z ∈ C, then q < z. If not, then by the first assumption on C, there would be a z such that x, z ∈ C and z ∈ (u, v). This implies that We have shown that y is an upper bound on the q ∈ Q for which there is a B r (a) ⊆ X with x ∈ B r (a) and B r (a) Φ ⇁ q. We need to show that y is least. So consider a z < y. Then x, z / ∈ C because y = inf{z ∈ R : x, z ∈ C}. Then there is a B r (a) × (u, v) enumerated into U that contains and B r (a) Φ ⇁ q. Thus y is indeed the required supremum. We have shown that, for all x ∈ X , f (x) = inf{z ∈ R : x, z ∈ C}. It is now easy to see that, for The analogous properties of upper semi-continuous functions can be proved by dualizing Proposition 4.2.
The next proposition is an RCA 0 version of the fact that a function f : X → R is continuous if and only if it is upper semi-continuous and lower semi-continuous. (i) If f : X → R is continuous, then there is a lower semi-continuous g : X → R and an upper semi-continuous h : Proof. (i) Let Φ be a code for a continuous function f : X → R. Define a code Γ for a lower semi- and a (u, v) with q < u. It is then easy to check that, for all x ∈ dom(f ), g(x) is defined and equal to f (x). The upper semi-continuous function h : X → R such that (∀x ∈ dom(f ))(f (x) = h(x)) is defined dually.
(ii) Let Γ be a code for a lower semi-continuous function g : X → R, and let Ψ be a code for an upper semi-continuous function h : X → R such that (∀x ∈ X )(g(x) = h(x)). Define a code Φ for a continuous function f : It is easy to see that Φ satisfies (cf2) and (cf3) of Definition 3.6. One can see that Φ satisfies (cf1) of Definition 3.6 by observing that if B r (a) Φ → (u, v), then (u, v) must contain the common value of g(a) and h(a).
We show that, for all

Honestly-Coded Potentials
Recall that we refer to lower semi-continuous functions f : X → R ≥0 as potentials. According to Definition 4.1, for X a complete separable metric space, Φ a code for a lower semi-continuous We call a code Φ for f honest if it contains all of the information of this sort. That is, if the 'if' is an 'if and only if.' Definition 5.1 (RCA 0 ). Let X be a complete separable metric space and let f : . If f has an honest code, then we say that f is honestly-coded.
Notice that if f : X → R is lower semi-continuous and Φ ⊆ N × X × Q >0 × Q is any set such that, for every B r (a) ⊆ X and every q ∈ Q, B r (a) Φ ⇁ q if and only if (∀x ∈ B r (a))(f (x) ≥ q), then Φ is automatically a code (and hence an honest code) for f as in Definition 4.1.
Every lower semi-continuous function admits an honest code, although such a code cannot always be constructed in a weak theory.
Lemma 5.2. Let X be a complete separable metric space.
(i) (WKL 0 ) If X is compact and f : X → R is lower semi-continuous, then there is a code Φ for f such that, for every B r (a) ⊆ X and every q ∈ Q, B r (a) Φ ⇁ q if and only if (∀x ∈ B r (a))(f (x) > q).
(ii) (ACA 0 ) If X is compact and f : X → R is lower semi-continuous, then f has an honest code. (iii) (ACA 0 ) If f : X → R is continuous and total, then there is an honestly-coded lower semicontinuous g : We have shown that, for every B r (a) ⊆ X and every q ∈ Q, B r (a) Φ ⇁ q if and only if (∀x ∈ B r (a))(f (x) > q). Using this fact, it is straightforward to verify that Φ is also a code for f in the sense of Definition 4.1.
(ii) Work in ACA 0 . Let Φ be a code for f as in (i). Then, define a code Γ by setting B r (a) Suppose that x ∈ B r (a) and B r (a) Then B s (b) Φ ⇁ t for every t < q, which means that f (x) > t for every t < q. Hence f (x) ≥ q.
Conversely, suppose that f (x) ≥ q for all x ∈ B r (a). If B s (b) ⊆ X and t ∈ Q satisfy t < q and We have shown that B r (a) Γ ⇁ q if and only if (∀x ∈ B r (a))(f (x) ≥ q). So Γ is an honest code for f .
(iii) In ACA 0 , we can define a code Φ by B r (a) Φ ⇁ q if and only if f (b) ≥ q for all b ∈ B r (a) ∩ X. One readily checks that Φ is an honest code for a lower semi-continuous g that is equal to f .
(iv) In Π 1 1 -CA 0 , we can directly define an honest code Φ for f by setting B r (a) Φ ⇁ q if and only if (∀x ∈ B r (a))(f (x) ≥ q).

Continuous envelopes
Honestly-coded lower semi-continuous functions facilitate the calculation of infima, which helps us approximate lower semi-continuous functions by continuous ones. To be precise, lower semicontinuous functions bounded below can be written as the increasing limit of continuous functions using the following construction. Although not needed for our purposes, it is instructive to observe that if f : X → R ≥0 is a potential, then f n converges pointwise to f as n → ∞. What we do need to prove is that continuous envelopes exist, and this can typically not be done within a weak theory. The construction of envelopes hinges on the following more general lemma. Lemma 6.2 (ACA 0 ). Let X and Y be complete separable metric spaces, let h : X × Y → R ≥0 be uniformly continuous, and let f : Y → R ≥0 be lower semi-continuous and honestly-coded with non-empty support. Then there is a uniformly continuous function g : X → R ≥0 such that Proof. Let Φ be a code for h, and let Ψ be an honest code for f . We first show that if x ∈ X , then inf y∈Y (h(x, y) + f (y)) indeed exists, which is a consequence of the following Claim.
Claim. Let x ∈ X and q ∈ Q. Then there is a y ∈ Y such that h(x, y)+f (y) < q if and only if there Proof of Claim. Suppose that y ∈ Y is such that h(x, y) + f (y) < q. Let u, v, p ∈ Q be such that h(x, y) ∈ (u, v), p > f (y), and v + p < q. Then there must be a B r (a) ⊆ X and a B s (u, v), and p are as required.
Conversely, suppose that there are such B r (a), B s (b), (u, v), and p. Because Ψ is honest and Thus, given x ∈ X , let Q be the set of all q ∈ Q for which there are a, r ∈ X × Q, b, s ∈ Y × Q, and u, v, q ∈ Q such that B r (a), B s (b), (u, v), and p witness that there is a y ∈ Y such that h(x, y) + f (y) < q as in the Claim. The set Q is bounded below by 0 and is non-empty since supp(f ) = ∅, so inf Q exists (essentially by [13, Theorem III.2.2]), and, by the Claim, inf Q = inf y∈Y (h(x, y) + f (y)). Henceforth, for each x ∈ X , let α x denote inf y∈Y (h(x, y) + f (y)).
We can make the above argument uniformly for all a ∈ X by letting A ⊆ X × Q be the set of all a, q for which there are r ∈ Q, b, s ∈ Y × Q, and u, v, q ∈ Q such that B r (a), B s (b), (u, v), and p witness that there is a y ∈ Y such that h(a, y) + f (y) < q. Then from A we can define the sequence (α a : a ∈ X) because, given a sequence of sets of rationals all bounded from below, ACA 0 suffices to produce the corresponding sequence of infima (that is ACA 0 proves item 4 of [13, Theorem III.2.2] uniformly).
Define a code Γ for a continuous partial function g : X → R by defining B r (a) It is easy to see that Γ satisfies the requirements of Definition 3.6. We need to show that g is indeed uniformly continuous on all of X and that (∀x ∈ X )(g(x) = α x ).
Claim. Let ε, δ ∈ Q >0 be such that By a symmetric argument, we also have that α x 0 ≤ α x 1 + ε, which gives the desired |α where the last inequality is by the choice of y and the fact that d X ×Y ( x 0 , y , Given x ∈ X and ε ∈ Q >0 , let δ ∈ Q >0 be such that and let a ∈ X be such that x ∈ B δ (a). Let (u, v) ⊆ R be such that [α a − ε /4, α a + ε /4] ⊆ (u, v) and v − u < ε. The Claim tells us that if c ∈ B δ (a) ∩ X, then α c ∈ [α a − ε /4, α a + ε /4] ⊆ (u, v), which means that B δ (a) Γ → (u, v). Likewise, the Claim implies that α x ∈ (u, v). Thus for every x ∈ X and every ε ∈ Q >0 , there are a ball B δ (a) ⊆ X and a (u, v) ⊆ R such that x ∈ B δ (a), α x ∈ (u, v), v − u < ε, and B δ (a) Γ → (u, v). Thus g(x) is defined and equals α x for all x ∈ X . Furthermore, the Claim clearly implies that g is uniformly continuous. Lemma 6.3 (ACA 0 ). Let X be a complete separable metric space, let f : X → R ≥0 be lower semicontinuous and honestly coded, and let α ∈ R ≥0 . Then there is a uniformly continuous function f α : X → R ≥0 such that, for all x ∈ X , Proof. This follows from Lemma 6.2 because the function h : X × X → R ≥0 given by h(x, y) = αd X (x, y) is uniformly continuous and bounded below by 0.

Critical Points of Continuous Functions
In this section we formalize Ekeland's variational principle and show that it has natural restrictions provable in weak systems. Recall that a potential on a complete separable metric space X is a lower semi-continuous function f : X → R ≥0 . Recall also that ε-critical points were defined in Definition 1.2 and that this definition may readily be formalized in RCA 0 using coded lower semi-continuous functions. With this, we are ready to define our formalized version (or, versions) of Ekeland's variational principle. Definition 7.1. Given definable classes X of coded complete separable metric spaces and F of coded potentials, the (formalized) free variational principle (FVP) for X ∈ X and f ∈ F is the statement that, if X ∈ X and f : X → R ≥0 is such that supp(f ) = ∅, then for every ε > 0 there is an x * ∈ supp(f ) such that The localized variational principle (LVP) is defined similarly, except that x 0 ∈ supp(f ) is given and When not mentioned, we assume that X is the class of all coded complete separable metric spaces and F is the class of all coded potentials. If we want to indicate that dom(f ) = X , we will say that f is total. Given c > 0, to indicate that f (x) ≤ c for all x ∈ dom(f ), we will say that f is c-bounded, and if we want to fix the value of ε to c, we call the statement the free/localized variational principle for ε = c. The free/localized variational principles for ε = c and f c-bounded will be denoted the c-FVP and the c-LVP, respectively.
Critical points are sometimes also called pseudo-minima, as they may serve as approximate minima of functions that do not actually attain their minimum value.
Lemma 7.2 (RCA 0 ). If X is any complete separable metric space and f : X → R ≥0 is lower semicontinuous, then for any x * ∈ X , f attains its minimum at x * if and only if x * is an ε-critical point of f for all ε > 0.

Proof. It is straightforward to see that if
Conversely, if f does not attain its minimum at x * , then we may choose x ∈ X with f (x) < f (x * ). By choosing ε small enough, we obtain The class F will contain either continuous or lower semi-continuous functions. Important special cases for us are the 1-FVP and the 1-LVP, which on occasion are equivalent to the FVP and LVP, respectively. Lemma 7.3 (RCA 0 ). Let X be a class of complete separable metric spaces and F be either the class of continuous or of lower semi-continuous potentials.
(1) The FVP and the LVP with X ∈ X and f ∈ F are equivalent, respectively, to the FVP and the LVP with ε = 1, X ∈ X, and f ∈ F. (2) If X is either the class of all complete separable metric spaces or of all compact metric spaces then the FVP and the LVP with X ∈ X and f ∈ F bounded are equivalent, respectively, to the 1-FVP and the 1-LVP with X ∈ X and f ∈ F. (3) If X is (a) a Banach space, (b) the Baire space, (c) the Cantor space, or (d) a closed ball in R n (with any norm), then the FVP and the LVP for X and for (arbitrary) bounded f are equivalent, respectively, to the 1-FVP and the 1-LVP for X . Proof.
(1) Replace f by f ′ = f /ε and note that any 1-critical point for f ′ is ε-critical for f .
(2) First replace f by f ′ = f /b, so that f ′ is bounded by 1 and any ε /b-critical point for f ′ is an ε-critical point for f . As we can no longer freely scale f ′ , we instead scale the metric and consider d ′ = εd /b. Then the reader can verify that any 1-critical point for f ′ with respect to d ′ is an ε-critical point for f with respect to d.
(3) The general idea is that in all of these cases, the proof of (2) can be simulated (in a possibly ad-hoc way) without modifying the space X . For the sake of illustration we sketch the proof in the case where X is a closed ball in R n -we give an informal argument and let the reader verify that it can be carried out in RCA 0 . The FVP and LVP cases are essentially the same, so we focus on the FVP.
Assume that the 1-FVP holds for X . Without loss of generality we may assume that X = B ρ (0) for some ρ > 0. Let f be a bounded lower semi-continuous function on X with non-empty domain, and let ε > 0. Without loss of generality we may assume that f is bounded by 1 /2 (adjusting ε if needed).
Let A ⊆ B ρ (0) ∩ Q n be finite and such that every point in B ρ (0) is within distance 1 /4 of some point in A. Let δ > 0 be small enough so that δ < min{ερ, 1 /4} and d(a, a ′ ) > 2δ whenever a, a ′ ∈ A are distinct. Define g : X → R by otherwise.
By the 1-FVP, let x * be a 1-critical point of g. We claim that x * ∈ B δ (a) for some a ∈ A. If not, then g(x * ) = 1 by the definition of g. Let a ∈ A minimize d(x * , a), and note that d(x * , a) < 1 /4 by our choice of A. Let y 0 ∈ supp(f ). Then x 0 := δ ρ y 0 + a ∈ B δ (a) and g( This contradicts that x * is a 1-critical point of g. Finally, we claim that y * := ρ δ (x * − a) is an ε-critical point of f . Let y ∈ supp(f ) with y = x * be arbitrary, and let x := δ ρ y + a ∈ B δ (a). Then since x * is a 1-critical point of g, which by the definition of g becomes as needed.
The proof that the 1-LVP implies the bounded LVP is similar, except that it is more convenient to replace A by the singleton {0}. The proofs of the other items are analogous, with the main difference being the choice of g. Let us assume that f is bounded by 1. For (3a) we set g(x) = f 1 ε x . For items (3b) and (3c) we use the observation that d(σ x, σ y) = 2 −|σ| d(x, y) for every σ, x, and y. Let n be large enough so that 2 −n < ε. For the FVP define g(σ y) = f (y), where |σ| = n. That is, given x, g(x) chops off x ↾ n and applies f to the remaining sequence y. For the LVP, we define g((0 n ) y) = f (y) and g(x) = 1 if x does not begin with n zeroes. We leave to the reader to check that in each of this cases, any 1-critical point for g induces an ε-critical point for f , satisfying the localization condition when appropriate. With Lemma 7.3 in mind, we often take ε = 1 or, in the bounded case, f bounded by 1, and we write critical point instead of 1-critical point. Note however that if we fix X beforehand, the FVP or LVP for X with bounded f are not necessarily equivalent to the 1-FVP or the 1-LVP for X , respectively, since we may not be able to perform the required scaling transformations without modifying the space. Claim (3) gives a few examples where such transformations may be performed, and while the list is by no means meant to be exhaustive, we conjecture that a space X can be found so that the 1-FVP and the FVP for X are not provably equivalent in RCA 0 .
Note also that in the cases (3a)-(3c), if the function f is continuous, then so is g. Thus in these cases, the claim also holds for the respective variational principles restricted to continuous functions. Our construction for (3d) does not preserve continuity, but it should also be possible to define someg which is continuous if f was (similar to the 2-envelope of g). Note however that some care would be required to constructg in RCA 0 . In any case, the current formulation of the lemma suffices for our purposes.
Let us now begin our analysis by showing that WKL 0 suffices to construct critical points of continuous functions on compact spaces. Proposition 7.4 (WKL 0 ). The FVP holds for compact X and continuous f ; in fact, in this setting f attains its minimum.
Proof. WKL 0 proves that every continuous function from a compact complete separable metric space to R attains a minimum value (see [13,Theorem IV.2.2] for the version of this fact with 'maximum' in place of 'minimum'). Thus let x * ∈ X be a point at which f attains its minimum value. Then x * is a critical point of f by Lemma 7.2.
When working over ACA 0 , we may drop the assumption that X is compact. Our proof is based on those in [2,4]. Proof. Let X = X be a complete, separable metric space with metric d, and in view of Lemma 7.3.1, assume that ε = 1. First we use ACA 0 to collect some information in order to implement the proof. Define S ⊆ X × X × Q >0 by and for a ∈ X and q ∈ Q >0 , write S(a, q) for {b ∈ X : (a, b, q) ∈ S}. Define a sequence of reals (u a,q : a ∈ X ∧ q ∈ Q >0 ) by u a,q = inf b∈S(a,q) f (b) for each a ∈ X and q ∈ Q >0 , which always exists because f is bounded from below and S(a, q) is non-empty (as it contains a). Next, define a sequence of reals (r a : a ∈ X) by r a = sup q∈Q >0 u a,q for each a ∈ X, which always exists because (∀q ∈ Q >0 )(u a,q ≤ f (a)). That the sequences (u a,q : a ∈ X ∧ q ∈ Q >0 ) and (r a : a ∈ X) can be defined in ACA 0 follows from the appropriately uniformized version of the (1)⇒(4) direction of [13, Theorem III.2.2] (and the analogous implication with 'greatest lower bound' in place of 'least upper bound' in (4)). Observe that (∀a ∈ X)(∀q 0 , q 1 ∈ Q >0 )(q 0 ≤ q 1 → u a,q 1 ≤ u a,q 0 ), which means that (∀a ∈ X)(r a = lim q→0 + u a,q ). Finally, define a function R : X × Q >0 → Q describing the rates of convergence of the sequences (u a,q : q ∈ Q >0 ) for each a ∈ X by letting R(a, p) = 2 −n , where n is least such that (∀q ∈ Q >0 )(q ≤ 2 −n → |r a − u a,q | < p). Now we define a sequence (a n : n ∈ N) of points in X converging to a critical point of f and a helper sequence (q n : n ∈ N) of points in Q >0 . Let a 0 be the first point (that is, the point with the least code) in X, and let q 0 = 2 −2 R(a 0 , 1). Given (a i : i ≤ n) and (q i : i ≤ n), let a n+1 be the first point in S(a n , q n ) such that f (a n+1 ) < u an,qn + 2 −(n+1) , and let q n+1 = 2 −(n+3) i≤n+1 R(a i , 2 −i ). The important property of (q n : n ∈ N) is that, for every n ∈ N, k≥n q k < min{2 −n , R(a n , 2 −n )}, which holds because (∀n)(∀k ≥ n)[q k ≤ 2 −(k+2) R(a n , 2 −n )].
As the sequence (f (a n ) : n ∈ N) is bounded from below, let ℓ = lim inf n∈N f (a n ) (which exists by [13,Lemma III.2.1] with 'lim inf' in place of 'lim sup'). Observe that lim inf n∈N u an,qn = ℓ as well because ∀n(u an,qn ≤ f (a n+1 ) < u an,qn + 2 −(n+1) ). Let i 0 < i 1 < i 2 < . . . be an increasing sequence of indices such that lim n∈N f (a in ) = ℓ. We show that the corresponding sequence (a in : n ∈ N) is Cauchy. Given M ∈ N, let N > M be large enough so that ∀n, m(N < n < m → |f (a in )−f (a im )| ≤ 2 −(M +1) ). Then, for every n, m ∈ N with N < n < m, we have that In the above expression, the first inequality is the triangle inequality, the second inequality is because a k+1 is chosen from S(a k , q k ) for every k ∈ N, the third inequality is obtained by cancelling the appropriate terms in the telescoping sum, and the fourth inequality is by the choice of N and by recalling that k≥in q k < 2 −in (and that i n ≥ n > N > M ). Thus (a in : n ∈ N) is Cauchy. By the (1)⇒(3) direction of [13, Theorem III.2.2], (a in : n ∈ N) converges to some x * ∈ X . We show that x * is a critical point of f . By the continuity of f , f (x * ) = lim n∈N f (a in ) = ℓ. We show that if y ∈ X is such that d(x * , y) ≤ f (x * ) − f (y), then f (y) = ℓ as well. Thus consider a y ∈ X such that d(x * , y) ≤ f (x * ) − f (y). Clearly f (y) ≤ ℓ because otherwise we would have the contradiction d(x * , y) < 0. So we show that f (y) ≥ ℓ. To do this, fix n ∈ N. We see that Thus d(a in , y) < f (a in ) − f (y) + R(a in , 2 −in ) because k≥in q k < R(a in , 2 −in ). It follows that f (y) ≥ u a in ,R(a in ,2 −in ) because y is in the open set and S(a in , R(a in , 2 −in )) is dense in U . Observe also that q in ≤ R(a in , 2 −in ), which implies that u a in ,q in −u a in ,R(a in ,2 −in ) < 2 −in . Therefore f (y) > u a in ,q in −2 −in . So we have shown that ∀n(f (y) > u a in ,q in − 2 −in ). As (u a in ,q in : n ∈ N) is a subsequence of (u an,qn : n ∈ N), it follows that lim inf n∈N u a in ,q in ≥ lim inf n∈N u an,qn = ℓ. Thus we conclude that f (y) ≥ ℓ, as desired. This completes the proof that if d(

Critical points of arbitrary potentials
Now let us consider the case where f is a possibly discontinuous potential. As it turns out, this general case can be reduced to the continuous case by using envelopes. To be precise, in order to find an α-critical point of a lower semi-continuous potential f , it suffices to find an α-critical point of the β-envelope f β for any β > α. Lemma 8.1 (RCA 0 ). Let X be a complete separable metric space, 0 < α < β, f : X → R ≥0 be a total potential with supp(f ) = ∅, and suppose that there is a total continuous function f β : X → R ≥0 such that, for every x ∈ X , βd(x, y)).
Then, for any x * ∈ X , (1) if x * is an α-critical point of f β , then f (x * ) = f β (x * ) and x * is an α-critical point of f .
(2) If f β attains its minimum at x * , then f attains its minimum at x * .
Proof. In view of Lemma 7.2, the second item is a consequence of the first: indeed, if f β attains its minimum at x * ∈ X , then for every α < β we have that x * is α-critical for f β , so that by the first item it is α-critical for f . Since α is arbitrary, f attains its minimum at x * . Thus we focus on the first item. Suppose that x * is an α-critical point of f β ; we begin by showing > 0 otherwise, and let δ ∈ Q >0 be such that f (y) > f β (x * ) + ε whenever d(x * , y) < δ. Such a δ can be obtained by letting Φ be the code for f ; letting B r (a) ⊆ X and q ∈ Q >0 be such that B r (a) Φ ⇁ q, x * ∈ B r (a), and q > f β (x * ) + ε; and then taking δ < r − d(a, x * ). Now let y ∈ X be such that Moreover, we cannot have that d(x * , y) < δ, for otherwise where the first inequality is by the choice of y and the second inequality is by the choice of δ and the assumption d(x * , y) < δ. Thus it must be that d(x * , y) ≥ δ. Therefore, where the first inequality is by the choice of y and the second inequality is because f β (y) ≤ f (y), δ ≤ d(x * , y), and min{(β − α)δ, ε} ≤ (β − α)δ. This means that x * is not an α-critical point of f β , which is a contradiction.
We have established that f (x * ) = f β (x * ). We now use this to show that x * is an α-critical point of f . Assume for a contradiction that this is not the case. Then there is a y ∈ X such that αd(x * , y) ≤ f (x * ) − f (y) but y = x * . Then, . This contradicts that x * is an α-critical point of f β . Thus x * is indeed an α-critical point of f .

Theorem 8.2.
(i) (ACA 0 ) The FVP holds for arbitrary X and any honestly-coded potential f . (ii) (ACA 0 ) The FVP holds for compact X and any potential f ; in fact, such an f attains its minimum. (iii) (Π 1 1 -CA 0 ) The FVP holds for arbitrary X and any potential f . Proof. (i) As f is assumed to be honestly-coded, the envelope f 2 exists and is continuous by Lemma 6.3. The function f 2 has a critical point by Theorem 7.5, and this critical point is also a critical point of f by Lemma 8.1.
(ii) As X is compact, f can be honestly coded by Lemma 5.2 item (ii). Thus f has a critical point by item (i) of this theorem. In fact, f 2 is defined and attains its minimum by Proposition 7.4, so that f also attains it minimum.
(iii) Working in Π 1 1 -CA 0 , we can assume that f is honestly-coded by Lemma 5.2 item (iv). Thus f has a critical point by item (i).
Below we will show that the points in Theorem 8.2 are optimal.

Reversals of the Variational Principle
In this section we show that many of the results of §7 and §8 reverse. Let us begin with the weakest version of the FVP we have considered. Recall that WKL 0 suffices to prove that every continuous potential over a compact space has a critical point. We now show that WKL 0 is also necessary to prove this fact. Proof. We work in RCA 0 and prove the contrapositive. If WKL 0 fails, then there is an infinite binary tree T ⊆ 2 <N that has no infinite path. Let T • be the set of leaves of T : Since T is infinite and has no infinite path, T • is also infinite. For each σ ∈ T • , define For each σ ∈ T , defineσ ∈ 2 <N with |σ| = 2|σ| asσ(2i) = 0 andσ(2i Here, S is the set of all binary strings τ which move away fromT before reaching a member ofT • . S can be defined in RCA 0 because each τ need only be checked against stringsσ of length at most |τ |. The elements ofT • ∪ S are pairwise incomparable, and for every x ∈ 2 N there is a σ ∈T • ∪ S such that x ⊒ σ. Indeed, each x must either reach a leaf ofT or move away fromT before that becauseT has no infinite path. Now, define a continuous function f : 2 N → [0, 3] as follows: One may easily obtain a code for f by Lemma 3.8 and Lemma 3.9. We show that f has no critical point, which gives the desired contradiction. If x ⊒ τ for some τ ∈ S, then take any σ ∈ T • and y ⊒σ, and observe that f (x) − f (y) ≥ 3 − 2 ≥ d(x, y). Thus x is not a critical point. Assume instead that x ⊒σ for some σ ∈ T • . Let i 0 be the greatest i < |σ| − 1 such that i / ∈ A σ , which exists because T is infinite. Then there is a σ ′ ∈ T • such that σ ′ ⊒ (σ ↾ i 0 ) (1 − σ(i 0 + 1)) and |σ ′ | > |σ|. By the maximality of i 0 , any τ ∈ T which extends σ ↾ (i 0 + 1) is shorter than σ ′ . Thus, we have that i 0 ∈ A σ ′ and that j ∈ A σ implies that j ∈ A σ ′ for every j < i 0 since σ ↾ i 0 = σ ′ ↾ i 0 . Take y ⊒σ ′ . Then d(x, y) ≤ 2 −2i 0 −1 , and therefore Thus x is not a critical point.
Next we consider versions of the variational principle provable in ACA 0 . Recall that ACA 0 is able to prove the FVP when either X is compact or f is continuous. Let us see that each of these cases implies ACA 0 , beginning with the latter.
Proposition 9.2. The FVP for continuous and total f on the Baire space implies ACA 0 over RCA 0 .
Proof. As is well-known, ACA 0 is equivalent to the statement "for every injection h : N → N, the range of h exists as a set." (see [13,Lemma III.1.3]).
Let h : N → N be an injection. For the purposes of this proof, we view every natural number as coding some finite set. For each n ∈ N and finite set D, let v n (D) denote the number of a ∈ D with h(a) < n: v n (D) = |{a ∈ D : h(a) < n}|. The fact that h is an injection implies that v n (D) ≤ n.
Define a continuous function g : We may use Lemma 3.8 to show that g can indeed be coded as a continuous function in RCA 0 , as it is straightforward to produce the sequence ( σ 0 N , g(σ 0 N ) : σ ∈ N <N ) and, for all n ∈ N and σ, τ ∈ N <N , to check that To see the above implication, observe that if d(x, y) < 2 −2 n , then x ↾ (2 n + 1) = y ↾ (2 n + 1). This means that the terms 2 −2k−1+v k (x(2 k )) and 2 −2k−1+v k (y(2 k )) agree for k ≤ n and therefore that |g(x) − g(y)| < ∞ k=n+1 2 −n−1 = 2 −n . We see that g(x) ≤ 1 for all x ∈ N N , thus the function f : N N → R ≥0 given by f (x) = 1 − g(x) is a continuous potential on the Baire space that is bounded by 1.
By the FVP on the Baire space, let x * be a critical point of f . For each n, let D n denote the set coded by x * (2 n ). We claim that D n must contain every a for which h(a) < n. Suppose not, and let a be such that h(a) < n but a / ∈ D n . Let y ∈ N N be such that y(2 n ) is a code for D ∪ {a} and y(m) = x * (m) for all m = 2 n . Then contradicting that x * is a critical point. Thus D n contains every a for which h(a) < n. We may then extract the range of h from x * by taking ran(h) = {n : (∃a ∈ D n+1 )(h(a) = n)}. Proof. We work in RCA 0 and prove the contrapositive. By Theorem 3.5, if ACA 0 fails, then there is a strictly increasing sequence c = (c n : n ∈ N) of rationals in [0, 1] with no supremum.
To define f , enumerate a code Φ by enumerating (u, v) Φ ⇁ q if q ≤ u or if q ≤ 2 and there is an n such that v < c n . One readily checks that Φ is a code for the potential f : [0, 1] → R ≥0 given by To ensure that Φ is honest, additionally enumerate (u, v) Φ ⇁ q whenever there is an n such that q ≤ c n < v. To see that the resulting code is honest, consider an open interval (u, v), and suppose that (∀x ∈ (u, v))(f (x) ≥ q). Note that f is bounded above by 2, so q ≤ 2. If there is an n such that v < c n , then (u, v) Φ ⇁ q. If c n < u for all n, then f (x) = x on (u, v). Thus q ≤ u, so (u, v) Φ ⇁ q. Finally, suppose that there is an n such that c n ∈ (u, v), but there is no n such that v < c n . As v is not the supremum of (c n : n ∈ N) (because we assumed that there is no such supremum), there is a y ∈ (u, v) such that ∀n(c n < y). Then f (y) = y, which implies that q ≤ y < v. By a similar argument, it cannot be that ∀n(c n < q) because if this were true, then there would be a z ∈ (u, v) with z < q such that ∀n(c n < z). As also f (z) = z, this contradicts the assumption that (∀x ∈ (u, v))(f (x) ≥ q). Thus it must be that q ≤ c n < v for some n, which implies that (u, v) Φ ⇁ q. Hence Φ is honest.
We claim that f has no critical point. Assume towards a contradiction that c * is a critical point of f . We show that c * is the supremum of c. Indeed, it is readily checked that if c * < c n for some n, then , and hence c * cannot be a critical point. It follows that c * ≥ c n for all n. Now, if c ′ < c * were also an upper bound of c, then we would have f (c ′ ) = c ′ , so that and thus c * cannot be a critical point. Hence c * is the supremum of c, contradicting our initial assumption.
Finally, we show that the unrestricted FVP proves Π 1 1 -CA 0 by appealing to the following characterization of Π 1 1 -CA 0 . Lemma 9.4 ([13, Lemma VI.1.1]). The following are equivalent over RCA 0 : (1) Π 1 1 -CA 0 (2) for any sequence (T i ) i∈N of subtrees of N <N , there is a set X such that for all i ∈ N, i ∈ X if and only if T i has an infinite path.
Proposition 9.5. The FVP for total potentials on the Baire space implies Π 1 1 -CA 0 over RCA 0 . Proof. By Proposition 9.2, the FVP on the Baire space implies ACA 0 over RCA 0 , so we may work over ACA 0 .
Recall that we assume that the pairing function ·, · : N×N → N is increasing in both coordinates. For the purposes of this proof, if x ∈ N N and i ∈ N, then (x) i ∈ N N is the function defined by (x) i (n) = x( i, n ). Similarly, if σ ∈ N <N and i ∈ N, then (σ) i ∈ N <N is the longest sequence such that (∀n Let (T i ) i∈N be a sequence of subtrees of N <N . We first define a code for the lower semi-continuous potential f : N N → [0, 1] given by To do this, define B r (σ) This shows that Φ correctly codes the desired potential f and that f is provably total in ACA 0 .
By the FVP, let x * be a critical point of f . Let X = {i : (x * ) i ∈ [T i ]}. We show that (∀i ≥ 0)(i ∈ X ↔ T i has a path). Clearly, if i ∈ X, then T i has a path. Suppose for a contradiction that there is a j such that T j has a path, but j / ∈ X. Let h ∈ [T j ], and let y ∈ N N be such that for all i, n ∈ N, This contradicts that x * is a critical point of f , which completes the proof.

The Localized Variational Principle
In this section we compare the strength of the free and localized variational principles in different contexts. First, we show that the two principles are equivalent when f is not assumed to be continuous. It is clear that the LVP implies the FVP, so we focus on the other direction. The following two lemmas aid the proof that the FVP implies the LVP.
Lemma 10.1 (RCA 0 ). Let X be a complete separable metric space, let f : X → R ≥0 be lower semicontinuous and total, and let C ⊆ X be closed. Then there is a total lower semi-continuous function g : X → R ≥0 such that Proof. Let Ψ be a code for f , and let U be a code for the complement of C. Enumerate a code Φ for g by enumerating B r (a) Since q was arbitrary we conclude that g(x) = f (x) given that both are the supremum of such q in R.
Lemma 10.2 (RCA 0 ). Let X be a complete separable metric space, and let f, g : X → R ≥0 be lower semi-continuous and total. Then h : X → R ≥0 given by h(x) = max{f (x), g(x)} is lower semi-continuous and total.
Proof. Let Ψ 0 be a code for f , and let Ψ 1 be a code for g. One easily enumerates a code Φ for h by enumerating B r (a) Lemma 10.3 (RCA 0 ). For every complete separable metric space X , the FVP for total potentials on X implies the LVP for total potentials on X .
Proof. Assume the FVP. Let f : X → R ≥0 be any potential, ε > 0, x 0 ∈ supp(f ), and let C be the closed set By Lemma 10.1 and Lemma 10.2, the functionf : X → R ≥0 given bỹ is lower semi-continuous. Let x * be an ε-critical point off . It must be that x * ∈ C, for otherwise we would have that x * = x 0 (as meaning that x 0 witnesses that x * is not an ε-critical point off . As x 0 , x * ∈ C and x * is critical forf , we have that , which yields x = x * , and thus x * is also an ε-critical point of f . We conclude that x * is an ε-critical point of f and that f ( Thus the FVP and the LVP for arbitrary f are equivalent. In contrast, the LVP for continuous functions suffices to prove the full FVP. To make this precise, we introduce the notion of pseudofibrations. Below, by a closed isometry we mean a continuous function f : for all x 0 , x 1 ∈ X and such that f [X ] is closed. We check that if f is a closed isometry and C ⊆ X is closed, then RCA 0 proves that f [C] is closed as well. Lemma 10.4 (RCA 0 ). Let X be a complete separable metric space, let C ⊆ X be closed, and let f : X → Y be a closed isometry. Then f [C] ⊆ Y is closed.
Proof. Let U be a code for the complement of C ⊆ X , and let V 0 be a code for the complement of (a), b) + s < r. We show that a y ∈ Y is in V if and only if there is no x ∈ C such that f (x) = y. This shows that V is the complement of f [C] and hence that f [C] is closed.
For y ∈ Y, we know that there is no x ∈ X such that y = f (x) if and only if there is a ball B s (b) containing y that is enumerated in V 0 . Thus it suffices to assume that there is an x ∈ X such that y = f (x) and show that y ∈ V if and only if x / ∈ C. Note that x is unique because f is an isometry. First suppose that x / ∈ C. Then x ∈ B r (a) for some ball B r (a) enumerated in U . We have that d Y (f (a), y) = d X (a, x) < r because y = f (x) and f is an isometry. Thus by choosing b sufficiently close to y, we see that there is a ball B s (b) containing y with d Y (f (a), b) + s < r. Thus y ∈ V.
Conversely, suppose that y ∈ V. Then there are balls B s (b) ⊆ Y and B r (a) ⊆ X such that Thus d X (a, x) < r because f is an isometry. Therefore x ∈ B r (a), so x / ∈ C.
Definition 10.5. Let X , Y be complete separable metric spaces. Say that a space Z is an Xpseudofibration of Y if there are a closed isometry ι : X × Y → Z and a continuous function π : Z → Y such that (1) for all z, z ′ ∈ Z, d Y (π(z), π(z ′ )) ≤ d Z (z, z ′ ) and (2) for all x, y ∈ X × Y, πι(x, y) = y.
Of course the typical example of an X -pseudofibration of Y is X × Y, but later we will see that there are others. Pseudofibrations are useful due to the following. (1) If X and Z are complete separable metric spaces such that Z is an X -pseudofibration of R ≥0 , then the LVP for total continuous potentials on Z implies the FVP for total potentials on X . (2) If X and Z are complete separable metric spaces such that Z is an X -pseudofibration of [0, 1], then the LVP for total, bounded continuous potentials on Z implies the 1-FVP for total potentials on X .
Proof. We give a uniform proof for the two claims. Note that by Lemma 7.3.1 we can also assume for the conclusion of the first claim that ε = 1. Let X be a complete separable metric space, let Y be either R ≥0 for the first claim or [0, 1] for the second, and let Z be an X -pseudofibration of Y with associated functions ι : X × Y → Z and π : Z → Y. Let f : X → Y be lower semi-continuous and total. By Proposition 4.2, the set note that if Y = [0, 1] thenf is bounded by 2. Every z ∈ Γ is of the form z = ι(x, y) for some x, y ∈ X × Y. For such a z, we then have that where the second equality is because z ∈ Γ (and therefore g(z) = 0), and the last equality is by Definition 10.5.2. Now, fix any x 0 ∈ supp(f ), let y 0 = f (x 0 ), and let z 0 = ι(x 0 , y 0 ). By the LVP for continuous potentials on Z, let z * ∈ Z be a critical point off that satisfiesf (z * ) ≤f (z 0 ) − d Z (z 0 , z * ). We first claim that z * ∈ Γ. To see this, observe that z 0 ∈ Γ by definition and thereforef (z 0 ) = π(z 0 ) = y 0 . We then have that by Definition 10.5.1 ≤ π(z 0 ) − (π(z 0 ) − π(z * )) = π(z * ).
Therefore we must have that g(z * ) = 0, which means that z * ∈ Γ. As z * ∈ Γ, it must be that z * = ι(x * , y * ) for some x * , y * ∈ ∆. Thus x * ∈ X and y * ≥ f (x * ). In fact, it must be that y * = f (x * ). To see this, suppose for a contradiction that y * > f (x * ), and let z = ι(x * , f (x * )). We then have that where the first equality is because z * and z are in Γ, and the second equality is because ι is an isometry. Thus z witnesses that z * is not a critical point off , which is a contradiction. Therefore y * = f (x * ), so z * = ι(x * , f (x * )).
We now show that x * is a critical point of the original f , which completes the proof. Let x ∈ X , and suppose that f (x * ) ≥ f (x) + d X (x, x * ). Let z = ι(x, f (x)). Then where the first equality is because ι is an isometry, and the second equality is because f (x * )−f (x) ≥ d X (x, x * ) and we use the max norm on X × Y. As z * and z are in Γ, we have that Therefore z = z * because z * is a critical point off , and since ι is injective, x = x * . We have shown that if x ∈ X satisfies f (x * ) ≥ f (x) + d X (x, x * ), then x = x * . Thus x * is a critical point of f .
Of course it follows from Lemma 10.6 that the LVP for total, continuous functions on X × R ≥0 implies the FVP for total potentials on X . However, the notion of pseudofibrations will allow us to replace X × R ≥0 by a more familiar space. In what follows, we will mainly deal with C [0, 1] . For given h ∈ C [0, 1] and a closed interval I ⊆ [0, 1], we write h I = sup t∈I |h(t)|. By the definition (coding) of C [0, 1] , statements of the form h I ≤ r are always Π 0 1 . Lemma 10.7 (RCA 0 ). Let X be a metric space and Y be a closed subinterval of R ≥0 . If X embeds by a closed isometry into C [0, 1] then C [0, 1] is an X -pseudofibration of Y.
Proof. Let Z = C [0, 1] , and let f : X → Z be a closed isometry. Let us write f x instead of f (x). Define ι : X × Y → Z by ι(x, y) (t) = 2tf x (0) + (1 − 2t)y if t < 1 /2, f x (2t − 1) if t ≥ 1 /2, and define π : Z → Y by π(g) = g(0). Intuitively, ι(x, y) represents y by its value on 0 and represents f (x) by its values on [ 1 /2, 1]. It is easy to check that a code for π can be constructed using Lemma 3.8. We may also use Lemma 3.8 to construct a code for ι. To do this, let X and Y be the dense sets of X and Y, respectively. It is straightforward to produce the sequence ( a, q , ι(a, q) : a, q ∈ X × Y ) and observe that d X ×Y ( a 0 , q 0 , a 1 , q 1 ) = max(d X (a 0 , a 1 ), d Y (q 0 , q 1 )) = d Z (ι(a 0 , q 0 ), ι(a 1 , q 1 )).
Thus the hypotheses of Lemma 3.8 are satisfied, so there exists a code for ι. Equation (3)  , which is a Π 0 1 condition because f [X ] is closed by assumption. Thus, f [X × Y] is closed by Lemma 3.7. It is then easy to check that ι and π make Z an X -pseudofibration of Y.
In order to apply Lemma 10.7, we need to show that many of the spaces we are interested in isometrically embed into C [0, 1] . Let us begin with the unit interval.  For the second, let X be the Baire space and Z be C [0, 1] . By Lemma 7.3.3b and Proposition 9.5, the 1-FVP for total f on X implies Π 1 1 -CA 0 . By Lemma 10.10, X embeds by a closed isometry into Z, so that by Lemma 10.7, Z is an X -pseudofibration of [0, 1]. Hence, reasoning as above, the LVP for total, bounded continuous functions on Z implies the 1-FVP for total potentials on X , from which we obtain Π 1 1 -CA 0 .

Conclusion
We have considered formalizations of Ekeland's variational principle with various natural restrictions and have shown that they are equivalent to well-known theories of second-order arithmetic. In this final section we synthesize these results to produce the definitive versions of our main results.
There are three main weakenings of the LVP we considered: the free, rather than localized, statement; the case where X is compact; and the case where f is continuous. When the LVP is weakened in the three ways simultaneously, we obtain a statement equivalent to WKL 0 . Proof. That (a) implies the other items is Proposition 7.4, while (c) implies (a) by Proposition 9.1.
If we choose two, but not three, of the weakenings, we instead obtain statements equivalent to ACA 0 . Moreover, if we impose only one of the three weakenings, we typically obtain statements that are not provable in ACA 0 . The only exception to this is the case where X is compact.