It is well known how to compute with real numbers intensionally, with equality of real numbers specified by an imposed equivalence relation on representations [1, 4, 12], such as Cauchy sequences or streams of digits. It has to be checked explicitly that functions on the representations preserve such equivalence relations. Discrete observations, such as finite decimal approximations, can be made because representations are given, but a different representation of the same real number can result in a different observation, and hence discrete observations are necessarily non-extensional.
In univalent mathematics, equality of real numbers can be captured by identity types directly, rather than by an imposed equivalence relation, thus avoiding the use of setoids. Preservation of equality of real numbers is automatic, but the drawback is that we are prevented from making any discrete observations of arbitrary real numbers. This kind of problem is already identified by Hofmann [8, Section 18.104.22.168] for an extensional type theory. Discrete observations of real numbers are made by breaking extensionality using a choice operator, which does not give rise to a function.
To avoid breaking extensionality, the central idea of this paper is to restrict our attention to real numbers that can be equipped with a simple structure called a locator. Such a locator is a strengthening of the locatedness property of Dedekind cuts. While the locatedness of a real number says that for rational numbers we have the property or , a locator produces a specific selection of one of and . In particular, the same real number can have different locators, and it is in this sense that locators are structure rather than property.
In a constructive setting such as ours, not all real numbers have locators, and we prove that the ones that do are the ones that have Cauchy representations in Section 3.8. However, working with locators rather than Cauchy representations gives a development which is closer to that of traditional real analysis. For example, we can prove that if has a locator, then so does , and this allows to compute when working constructively, so that we say that the exponential function lifts locators. As another example, if is given a modulus of continuity and lifts locators, then has a locator and we can compute the integral in this way.
Thus the difference between locatedness and locators is that one is property and the other is structure. Plain Martin-Löf type theory is not enough to capture this distinction because, for example, it allows to define the notion of locator as structure but not the notion of locatedness as property, and therefore it does not allow to define the type of Dedekind reals we have in mind, whose identity type should capture directly the intended notion of equality of real numbers. A good foundational system to account for such distinctions is univalent type theory (UTT), also known as homotopy type theory . For us, it is enough to work in the fragment consisting of Martin-Löf type theory with propositional truncation, propositional extensionality and function extensionality (see Section 2). The need for univalence would arise only when considering types of sets with structure such as the type of metric spaces or the type of Banach spaces for the purposes of functional analysis.
We believe that our constructions can also be carried out in other constructive foundations such as CZF, the internal language of an elementary topos with a natural numbers object, or Heyting arithmetic of finite types. Our choice of UTT is to some extent a practical one, as it is a constructive system with sufficient extensionality, which admits, at least in theory, applications in proof assistants allowing for computation using the techniques in this paper.
In summary, the work has two aspects. One aspect is that instead of working with functions on intensional representations, we work with functions on real numbers that lift representations. The second aspect is the particular representation that seems suitable.
We describe the assumptions on the foundational system in Section 2.
The definition and basic theory of locators is given in Section 3. We construct locators for rationals in Section 3.2. We discuss preliminaries for observing data from locators in Sections 3.3 and 3.4, which is then used to compute rational bounds in Section 3.5. We compute locators for algebraic operations in Sections 3.6 and for limits in Section 3.7. We compute signed digit representations for reals with locators in Section 3.8. Given a real and a locator, we strengthen the properties for being a Dedekind cut into structure in Section 3.9.
We work in type theory with universes and with , identity types for , a unit type , an empty type , a natural numbers type , dependent sum types , dependent product types and propositional truncation (see Section 2.1). We assume function extensionality, which can be stated as the claim that all pointwise equal functions are equal. We assume propositional extensionality, namely the claim that if and are propositions in the sense of Section 2.1, and and , then .
A proposition is a type all whose elements are equal, which is expressed type-theoretically as
We have the type of all propositions, and we conflate elements of with their underlying type, that is, their first projection.
We assume that every type has a propositional truncation.
The propositional truncation of a type is a proposition together with a truncation map such that for any other proposition , given a map , we obtain a map .
The uniqueness of the obtained map follows from the fact that is a proposition, and function extensionality.
We may also think of propositional truncations categorically, in which case they have the universal property that given a map as in the diagram below, we obtain the vertical map, which automatically makes the diagram commute because is a proposition, and which is automatically equal to any other map that fits in the diagram.
X [r,”— ⋅ —”] [rd] & ∥ X ∥ [d,dashrightarrow]
Propositional truncations can be defined as higher-inductive types, or constructed via impredicative encodings assuming propositional resizing.
Truncated logic is defined by the following, where and [15, Definition 3.7.1]:
We use the following terminological conventions throughout the work.
We refer to types that are propositions as properties. We refer to types which may have several inhabitants as data or structures. We indicate the use of truncations with the verb “to exist”: so the claim “there exists an satisfying ” is to be interpreted as , and “there exists an element of X” is to be interpreted as . Most other verbs, including “to have”, “to find”, “to construct”, “to obtain”, “to get”, “to give”, “to equip”, “to yield” and “to compute”, indicate the absence of truncations.
One attempt to define when is a surjection is
In fact, this is rather called split surjective, as from that structure, we obtain a map which is inverse to : so we have defined when a function is a section. Rather defining surjectivity as
by virtue of using the property , does not yield an inverse map.
In words, we say that is a surjection if for every there exists a pre-image. The requirement that every has a pre-image means a choice of pre-images, that is, it means equipping elements of to elements of .
Given a function , the image of is the collection of elements that are reached by , that is, for which there is an element such that . The propositions-as-types interpretation would formalise this as
However, because the type is contractible [15, Lemma 3.11.8], in fact this type is equivalent to the type itself, in the sense that there is a map with a left pointwise inverse and a right pointwise inverse, and so it does not adequately represent the image of .
Using truncations, we instead formalise the image of as the collection of elements of for which there exists a pre-image along , that is, in UTT the image of is formalised as:
noting that the inner is truncated whereas the outer is not: we want to distinguish elements in the image of , but we do not want to distinguish those elements based on a choice of pre-image in .
We may compute the integral of a uniformly continuous function as:
The construction of the limit value, e.g. as in Lemma 3.7.2, uses the modulus of uniform continuity of as in Definition 4.0.4. However, since the integral is independent of the choice of modulus, by unique choice, e.g. as in Theorem 5.4 of , the existence (defined constructively as in Definition 2.1.3) of a modulus of uniform continuity suffices to compute the integral. We discuss this further in Sections 3.7 and 4.1.
2.2 Dedekind reals
Although the technique of equipping numbers with locators can be applied to any archimedean ordered field, for clarity and brevity we will work with the Dedekind reals as defined in The Univalent Foundations Program .
A predicate on a type is a map . For we write .
A Dedekind real is defined by a pair of predicates on with some properties. To phrase these properties succinctly, we use the following notation for :
This is justified by the fact that holds iff , with the canonical inclusion of the rationals into the Dedekind reals.
A pair of predicates on the rationals is a Dedekind cut or Dedekind real if it satisfies the four Dedekind properties:
bounded: and .
rounded: For all ,
transitive: for all .
located: for all .
The collection of pairs of predicates together with proofs of the four properties, collected in a -type, is called the Dedekind reals.
The Univalent Foundations Program  has disjointness
instead of the transitivity property, which is equivalent to it in the presence of the other conditions, and it is this disjointedness condition that we use most often in proofs.
Assuming transitivity, if , then transitivity yields , which contradicts irreflexivity of on the rationals, which shows disjointedness.
Conversely, if and , apply trichotomy of the rationals on and : in case that we are done, and in the other two cases we obtain , contradicting disjointness. ∎
For Dedekind reals and , we define the strict ordering relation by
where means , and their apartness by
As is typical in constructive analysis, we have , but not the converse.
Recall that is located if .
A locator for is a function . We denote by the type of locators on . That is, we replace the logical disjunction in locatedness by a disjoint sum, so that we get structure rather than property, allowing us to compute.
This structure has been used previously by The Univalent Foundations Program in a proof that assuming either countable choice or excluded middle, two types of real numbers coincide [15, Section 11.4].
The reader may wonder why we only choose to modify one of the Dedekind properties to become structure. We show in Theorem 3.9.2 that given only a locator, we can obtain the remaining structures, corresponding to boundedness, roundedness and transitivity, automatically.
The following example, which will be fully proved in Theorem 4.2.4, illustrates how we are going to use locators. Suppose is a pointwise continuous function, and are real numbers with locators. Further suppose that is locally nonconstant, that has a locator whenever has a locator, and that . Then we can find a root of
, which comes equipped with a locator. For the moment, we provide a proof sketch, to motivate the techniques that we are going to develop in this section. We define sequencesand with , with , with , and such that all and have locators. Set , . Suppose and are defined. We will explain in the complete proof of Theorem 4.2.4 how to to find with and . The important point for the moment, is that this is possible precisely because we have locators.
If , then set and .
If , then set and .
The sequences converge to a number . For any , we have , hence . This completes our sketch.
We need to explain why the sequences and come equipped with locators, and why their limit has a locator. In fact, all are rationals, and hence have locators, as discussed in Section 3.2. The construction of in uses the techniques of Sections 3.3 and 3.4. Locators for and can be constructed using the techniques of Section 3.6. Locators for limits are discussed in Section 3.7.
3.1 Terminology for locators
A locator for a real can be evaluated by picking and . The value has type , and so can be either in the left summand or the right summand. We say that “we locate ” when the locator gives a value in the left summand, and similarly we say “we locate ” when the locator gives a value in the right summand.
We often do case analysis on by constructing a value for some type family . To construct we use the elimination principle of , for which we need to specify two values corresponding to the disjuncts and , so the two values have corresponding types and . These two values correspond to the two possible answers of the locator, and we will often indicate this by using the above terminology: the expression “we locate ” corresponds to constructing a value of the former type, and the expression “we locate ” corresponds to constructing a value of the latter type.
For example, for every real with a locator , we can output a boolean depending on whether locates or . Namely, if we locate we output true, and if we locate we output false. We use this construction in the proof of Lemma 3.9.1.
3.2 Locators for rationals
Suppose is a rational, or more precisely, that , where is the canonical inclusion of the rationals into the Dedekind reals, then has a locator.
We give two constructions, to emphasise that locators are not unique. We use trichotomy of the rationals, namely, for all ,
In either case, since there is at most one rational with , we may assume to be given. We conflate with .
Let be arbitrary, then we want to give . By trichotomy of the rationals applied to and , we have
In the first case , we can locate . In the second case , we have , so we locate . In the third case, we have , so we locate . ∎
Let be arbitrary, then we want to give . By trichotomy of the rationals applied to and , we have
In the first case , we can locate . In the second case , we have , so we locate . In the third case, we have , so we locate . ∎
In the case that , the first construction locates , whereas the second construction locates . In particular, given a pair of rationals, the first proof locates if is indeed negative, and otherwise. The second proof locates if is indeed positive, and otherwise. Note that these locators disagree when , illustrating that locators are not unique.
3.3 The logic of locators
Our aim is to combine properties of real numbers with the structure of a locator to make discrete observations.
If one represents reals by Cauchy sequences, one obtains lower bounds immediately from the fact that any element in the sequence approximates the real up to a known error. As a working example, we show, perhaps surprisingly, that we can get a lower bound for a real , that is an element of , from the locator alone. From the definition of Dedekind cuts, we know that there exists a lower bound, that is, . With the elimination rule for propositional truncations in mind, we use this to construct a proposition which gives us a bound.
More concretely, we define a type of rationals which are bounds for and which are minimal in a certain sense. The minimality is not intended to find tight bounds, but is intended to make this collection of rationals into a proposition: in other words, minimality ensures that the answer is unique, so that we may apply the elimination rule for propositional truncations.
Our technique has two central elements: reasoning about the structure of locators using propositions, and the construction of a unique answer using bounded search (Section 3.4).
Given a locator , and , we have the notation
leaving the proof of implicit. We further often drop the choice of locator, writing for .
A decidable proposition is a proposition such that . We have the collection
of decidable propositions. We conflate elements of with their underlying proposition.
If and are decidable, then so is , and we use this fact in later developments.
The type of Definition 3.0.1 is equivalent to the type
Given a locator , define to be true when the locator determines to be on the right of the lower bound , that is, when the locator lands in the left summand, and false when the locator determines to be on the left of the lower bound . Straightforwardly, satisfies the two conditions.
In the other direction, given , we obtain a locator by setting to locate when , and to locate otherwise. ∎
For a real with a locator and rationals , we write
for the decidable proposition obtained from Lemma 3.3.2. We write
to be the negation of : so it is the proposition which is true if we locate .
In general, if we have , then does not imply .
For any real with a locator ,
By the fact that if then , and using the fact that when is decidable. ∎
Let be a real equipped with a locator. We can type-theoretically express that the locator must give certain answers. For example, if we have , shown visually as
we must locate , because . In other words, we obtain truth of the proposition : the property yielded a property of the structure .
Continuing our working example of computing a lower bound, for any we have the claim
that we locate . This claim is a decidable proposition. And from the existence of a lower bound for , we can deduce that , because if then and hence the above lemma applies. If we manage to find a for which holds, then we have certainly found a lower bound of , namely .
3.4 Bounded search
Even though the elimination rule for propositional truncation in Definition 2.1.2 only constructs maps into propositions, we can use elements of propositional truncations to obtain witnesses of non-truncated types — in other words, we can sometimes obtain structure from property.
Let . If then we can construct an element of .
Even without univalence, Theorem 3.4.1 also works for any type equivalent to .
Let be a type and be an equivalence, that is, a function with a left inverse and right inverse. Let . If then we can construct an element of .
3.5 Computing bounds
We are now ready to finish our running example of computing a lower bound for .
Given a real equipped with a locator, we get bounds for , that is, we can find with .
We pick any enumeration of , that is, an equivalence . Set
Upper bounds are constructed by a symmetric argument, using
We emphasise that even though we cannot decide in general, we can decide what the locator tells us, and this is what is exploited in our development. Given a real with a locator, the above construction of a lower bound searches for a rational for which we locate . We emphasize once more that the rational thus found is minimal in the sense that it appears first in the chosen enumeration of , and not a tight bound.
The proof of Theorem 3.4.1 works by an exhaustive, but bounded, search. So our construction for Lemma 3.5.1 similarly exhaustively searches for an appropriate rational . The efficiency of the algorithm thus obtained can be improved:
We do not need to test every rational number: it suffices to test, for example, bounds of the form for , as there always exists a bound of that form. Formally, such a construction is set up by enumerating a subset of the integers instead of enumerating all rationals, and showing the existence of a bound of the chosen form, followed by application of Corollary 3.4.2.
More practically, Lemma 3.5.1 shows that we may as well additionally equip bounds to reals that already have locators. Then, any later constructions that use rational bounds can simply use these equipped rational bounds. This is essentially the approach of interval arithmetic with open nondegenerate intervals.
For a real equipped with a locator and any positive rational we can find with and .
The construction of bounds in Lemma 3.5.1 yields with . We can compute such that . Consider the equidistant subdivision
By Lemma 3.3.4, necessarily because . Similarly, we have because .
For some , which we can find by a finite search, we have
For this , we can output and . ∎
We may be able to compute arbitrarily precise bounds for a real number with a locator. But, as in the remark below Lemma 3.5.1, the above theorem shows that we may as well equip an appropriate algorithm for computing arbitrarily precise lower and upper bounds to real numbers.
3.6 Locators for algebraic operations
We will show that if and have locators, then so do , , , (assuming ), and , where we assume these to be defined as in The Univalent Foundations Program [15, Section 11.2.1]. The proofs below give algorithms for computing with locators.
The Dedekind reals satisfy the archimedean property, which can be succinctly stated as the claim that for all ,
We write for the positive rationals.
For real numbers , there exist and with .
By a first application of the archimedean property, we know . Since we are showing a proposition, we may assume given such an . Now for , by the archimedean property, we know , and again we may assume to have such a . Now set and . ∎
For reals and equipped with locators we have the archimedean structure
For reals and equipped with locators, and a rational, if then we have a choice of or , that is:
By Lemma 3.6.2 we can find with . Apply trichotomy of the rationals: if or then we locate , and if then we locate . ∎
Instead of the rational we can have any real equipped with a locator in the above corollary, so that we obtain a form of strong cotransitivity of the strict ordering relation on the real numbers, but we will not be using this.
If one works with real numbers intensionally, such as when they are given as Cauchy sequences, then one defines the algebraic operations on the reals directly by specifying how to compute the output representations. We work with an arbitrary notion of real numbers with given algebraic operations, and so the construction of locators has to be done explicitly.
If and are equipped with locators, then so are , , , (assuming ), and .
As we define absolute values by , as is common in constructive analysis, if has a locator, then so does , and we use this fact in the proof of the above theorem.
Proof of Theorem 3.6.4.
Throughout this proof, we assume and to be equipped with locators, and to be rationals.
We construct a locator for . We can give by considering .
We construct a locator for . We need to show . Note that iff there exists with and . Similarly, iff there exists with and .
Set , such that . By Lemma 3.5.2 we can find such that and , so in particular . Set , so that . Now consider . If we locate , we locate . If we locate , we have , that is, we can set to locate .
We construct a locator for . We consider both and . If we locate or , we can locate . Otherwise, we have located both and , so we can locate .
The locator for is symmetric to the case of .
We construct a locator for . We need to show . Note that means:
Using Lemma 3.5.2 we can find with and , since we have already constructed locators for , , and all rationals.
Set and . Find and such that and . Note that and similarly , and . Then the distance between any two elements of is less than . For instance, because , and and similarly . Hence . Thus, by dichotomy of the rationals, one of and must be true, yielding a corresponding choice of .
We construct a locator for . Consider the case that . Given , we need , or equivalently . By the previous case, and have locators, so we can apply Corollary 3.6.3. The case is similar. ∎
This proof works whether we use a definition of algebraic operations as in The Univalent Foundations Program , or whether we work with the archimedean field axioms, because from the archimedean field axioms we deduce the same properties as the definitions.
3.7 Locators for limits
For a sequence of reals , regarded as a function , a a modulus of Cauchy convergence is a map such that
The following is based on the The Univalent Foundations Program [15, Theorem 11.2.12].
If there exists a modulus of Cauchy convergence for a sequence of reals, then there is a unique real , called the limit, such that the sequence converges to the usual sense:
Uniqueness of is well-known, and importantly for us, makes the conclusion into a proposition, so that we may assume to be given a modulus of Cauchy convergence . The limit may then be given as a Dedekind cut defined by:
Inhabitedness and roundedness of are straightforward. For transitivity, suppose , then we wish to show . There exist with and . Now , so either or , and in either case .
For locatedness, suppose . Set , so that . By locatedness of , we have , hence .
In order to show convergence, let , set , and let . We need to show , or equivalently, . For , suppose that , or equivalently, . There exist with , or equivalently, , which contradicts being a modulus of Cauchy convergence. We can similarly show . ∎
We denote limits of sequences by .
Example 3.7.3 (Exponential function).
We can define the exponential function as . We obtain the existence of a modulus of Cauchy convergence by boundedness (as in Definition 2.2.2) of .
Suppose has modulus of Cauchy convergence , then for all :
We show . Suppose that , or equivalently . There exist with , that is, , contradicting that is a modulus of Cauchy convergence.
can be shown similarly. ∎
Suppose has modulus of Cauchy convergence , and suppose that every value in the sequence comes equipped with a locator, that is, suppose we have an element of Then we have a locator for .
Let be arbitrary rationals. We need . Set so that . We consider by doing case analysis on . If we locate then we can locate . If we locate then we can locate . ∎
Example 3.7.6 (Locators for exponentials).
Given a locator for , we can use Lemma 3.5.1 to obtain a modulus of Cauchy convergence of . Hence has a locator.
Many constants such as and have locators, which can be found by examining their construction as limits of sequences.
3.8 Calculating digits
We would like to print digits for numbers equipped with locators, such as . Such a digit expansion gives rise to rational bounds of the number in question: if a digit expansion of starts with , then we have the bounds .
We now wish to generate the entire sequence of digits of a real number equipped with a locator. As in computable analysis and other settings where one works intensionally, with reals given as Cauchy sequences or streams of digits, we wish to extract digit representations from a real equipped with a locator.
In fact, various authors including Brouwer  and Turing  encountered problems with computing decimal expansions of real numbers in their work. As is common in constructive analysis, we instead consider signed-digit representations.
A signed-digit representation for is given by and a sequence of signed digits , with , such that
The number may be given by a signed-decimal expansion as , or as , or as .
For any equipped with a locator, we can find such that .
Use Lemma 3.5.2 with to obtain rationals with and . Set . Then:
For a real number , locators and signed-digit representations are interdefinable.
If a real number has a signed-digit representation, then it is the limit of a sequence of rational numbers, and so by Lemma 3.7.5 it has a locator.
Conversely, assume a real has a locator. By Lemma 3.8.4 we get with . Consider the equidistant subdivision
By applying the locator several times, we can find a signed digit such that
We find subsequent digits in a similar way. ∎
The Cauchy reals is the collection of rational sequences equipped with a modulus of Cauchy convergence, quotiented by a relation that relates and if