Higher-Order Functions and Brouwer's Thesis

Extending Mart\'in Escard\'o's effectful forcing technique, we give a new proof of a well-known result: Brouwer's monotone bar theorem holds for any bar that can be realized by a functional of type $(\mathbb{N} \to \mathbb{N}) \to \mathbb{N}$ in G\"odel's System T. Effectful forcing is an elementary alternative to standard sheaf-theoretic forcing arguments, using ideas from programming languages, including computational effects, monads, the algebra interpretation of call-by-name ${\lambda}$-calculus, and logical relations. Our argument proceeds by interpreting System T programs as well-founded dialogue trees whose nodes branch on a query to an oracle of type $\mathbb{N}\to\mathbb{N}$, lifted to higher type along a call-by-name translation. To connect this interpretation to the bar theorem, we then show that Brouwer's famous"mental constructions"of barhood constitute an invariant form of these dialogue trees in which queries to the oracle are made maximally and in order.


Introduction
It is right to rebel! A major theme of Bob Harper's thinking has been the critique of universal computation as a scientific explanation of functional programming, which is fundamentally about higher-order functions rather than functions between the natural numbers. Indeed, many sensible models of computation do not coincide with Turing computability at higher type, a critical observation for the era of the socialization of computation, in which programs increasingly act as interacting nodes in complex systems.
An early exponent of this perspective was the Dutch topologist L.E.J. Brouwer, who based his intuitionistic program of mathematics on a profound reconstruction of the notion of higher-order function in terms of infinitary dialogues, rejecting both the classical emphasis on static relations, and the (proto-)constructivist fixation on finitude and formal definability.
The morphisms of frames abstract the behavior of the inverse images f * : O Y O X of continuous maps of topological spaces f : X Y . We obtain, therefore, a possible notion of constructive space by considering the formal dual of frames -by "dual" we mean that a constructive space is just a frame, but a morphism between constructive spaces goes in the opposite direction. 1 Definition 1.2 (Constructive space). A constructive space X is defined by a frame, conventionally called O X ; a continuous map of constructive spaces f : X Y is given by a morphism of frames f * : O Y O X , called the inverse image.
Then, geometrical figures like points are defined synthetically in terms of continuous maps. The constructive space corresponding to a single point * is given by the frame O * = {⊥ < ⊤}; then, one may define a point of an arbitrary constructive space X to just be a continuous map x : * X. Unraveling definitions, this turns out to be the same as a completely prime filter in O X , but it is not important for our purposes to know this definition.

Brouwer's presentation of constructive spaces as spreads
Intuitionists (like Brouwer and Weyl) and their forbears (like Poincaré) were not only concerned with the law of the excluded middle and the axiom of choice; they also did not accept the use of impredicative definitions, where the object being defined may implicitly refer to itself. In particular, the existence of the powerset P(X), the set of all subsets of X, was considered doubtful. Unfortunately, many aspects of the theory of constructive spaces are impredicative in just this sense, but it is possible to present constructive spaces by generators and relations in a predicative way -just like the infinite set of natural numbers can be presented by finitely many generators in a programming language: datatype nat = Z | S of nat For his purposes in developing intuitionistic analysis, i.e. the study of the continuum from the intuitionistic perspective, Brouwer developed such a presentation of constructive spaces called spreads, in which the algebraic structure of opens is made concrete in terms of finite paths in an infinitely broad and infinitely deep rooted tree.

1.
is the empty list. 2. u is the singleton list given u : S. 3. u + + v is the list obtained by appending v to the end of u. 4. We write len( u) for the length of the list u. 5. We write v :: u for v + + u, and uˆv for u + + v . 6. We write u v to assert that u is a prefix of v. Notation 1.4 (Infinite sequences). If S is a set, then N → S is the set of infinite sequences of elements of S, which we manipulate using the following notations: 1. We write take(k, α) to mean the list comprised of the first k elements of α. 2. We write α ≻ u or u ≺ α to assert that u : list(S) is a finite prefix of α : N → S. Definition 1.5 (Spread law). A spread law is a decidable set B of lists u : list(N) called "basic observations", 2 satisfying the following axioms that make B encode an infinitely wide and deep rooted tree: 1. The empty sequence is in B; this ensures that the resulting tree is rooted. 2. If v ∈ B, then for any prefix u v, we have u ∈ B. 3. If u ∈ B, then there exists some k : N such that the extension uˆk is in B; this ensures that the tree is infinitely deep.
To view the spread law as an encoding of a tree, think of each u ∈ B as a sequence of directions to move from the root of the tree to one of its nodes. A spread, defined below, is the geometrical object corresponding to the algebraic data of a spread law.
Definition 1.6 (Spread). A spread S is defined by the data of a spread law B S ; one thinks of S as the "space of infinite paths" of the tree encoded by B S .
It is useful to switch freely between the intuition of u as a node in a tree and of u as an observation about an infinite path in a tree, substantiated by the fact that each list u determines the set of infinite sequences that it prefixes. While the data of a spread is the same as the data of a spread law, we define them separately because a function between spread laws, suitably defined, should encode the inverse image part of a continuous function between spreads.
Definition 1.7 (Points). A point of a spread S is an infinite path in the tree encoded by B S , i.e. an infinite sequence α : N → N such that each finite prefix u ≺ α is in B S , i.e. take(k, α) ∈ B S for all k : N.
A basic observation in a spread is then conceptually similar to a basic open in a basis for a topology, e.g. an open interval on the real line. From this perspective, the empty list represents the entire spread S, and a general prefix u represents the subspace of S spanned by points that begin with u.
Example 1.8 (Real numbers). Of central importance is the continuum R, the spread of real numbers. One construction of this spread involves an encoding of rational intervals as natural numbers; then a list of natural numbers u is admitted in B R just when its elements encode increasingly smaller nested rational intervals each of the form a 2 n−1 , a+1 2 n−1 . A point α in the resulting spread R is an encoding of a real number, and one may identify the collection R of real numbers with the equivalence classes of R-points under the suitable relation (van Atten et al., 2002). Definition 1.9 (Fans, or finitary spreads). A spread whose nodes are all finitarily branching is called a fan; an example of such a finitary spread is the fan I representing the closed interval [0, 1] ⊂ R. As above, we may write I for the appropriate collection of equivalence classes of I-points.

Brouwer's bar thesis: higher-order functions as trees
In classical topology, an open cover over an open U ∈ O X is a set of opens {V i ∈ O X | i : I} such that every point x ∈ U is contained in one of the V i . Brouwer defined an analogous notion of cover for spreads, which he called a bar, also in terms of points.
Definition 1.10 (Bars in terms of points). Let S be a spread and let u ∈ B S be a basic observation; then a bar over u is given by a subset Q ⊆ B S satisfying the following axioms: 3 We write u ⊳ Q to assert that Q is a bar over u; colloquially, the covering axiom states that every infinite path α eventually "hits the bar" Q, as depicted in Fig. 1. It is useful to observe that the covering axiom is equivalent to the assertion that for every α ≻ u, there exists k : N such that take(k, α) ∈ Q.
Given that the empty observation represents the entire spread S (because every point α is prefixed by ), one refers to a bar of S as a subset Q ⊆ B S such that ⊳ Q.

Intuitionistically, bars are higher-order functions
From the point of view of the Brouwer-Heyting-Kolmogorov interpretation of the logical connectives (Heyting, 1956), to say that Q is a bar over u is the same as to require a higher-order function φ : (N → N) → N such that for all α ≻ u, we have take(φ (α), α) ∈ Q. Intuitively, this higher order function receives a point and responds with how far one must proceed along the point's approximations in order to reach the bar.

Bars represented by well-founded trees
It is an empirical reality that one cannot define a discontinuous function on the reals by computational means -this is because such functions always rely on the ability to branch on whether two real numbers are equal, or something analogous, which cannot be achieved S α Q v α in finite time. Consequently, it was important for Brouwer's intuitionistic version of analysis to reflect this limitation in a continuity theorem: all functions defined on the reals are continuous.
In fact, the crown jewel of Brouwer's intuitionistic analysis is the verification of the even stronger uniform continuity theorem for all total functions defined on the closed interval, which exhibits not only a modulus of continuity for such functions, but one that is independent of the input: For intuitionistic mathematicians, uniform continuity is important because it reflects the limitations of human facilities for manipulating infinitary data: a human can only make finitely many observations of infinite data. The uniformity condition expresses that, in the case of the closed interval, one may bound the number of observations regardless of the point being observed. From a computer science point of view, the uniform continuity theorem suggests a realistic invariant on nodes that consume and emit bits of data: there is a bound on how many messages it takes to engender a response.
Because Brouwer represented the closed interval I in terms of the points of a fan (Definition 1.9), he could reduce the statement of uniform continuity to a combination of ordinary continuity and his famous fan theorem, a statement about bars Q on the fan F whose basic observations are all lists of bits 0, 1: Observe that the fan theorem is nothing more than a quantifier rotation: the assumption that Q is a bar associates to each sequence α the length k of a basic observation of α that lands in the bar; the conclusion of the fan theorem establishes a uniform bound on the length of this finite prefix for all α. In the depicted tree, each node is labeled with the list of bits that it codes; to be precise, a node labeled η u represents a proof of u ◭ Q that is a leaf node, and a node labeled ϝ u represents a proof of u ◭ Q that is a branching node.
Brouwer argued for his fan theorem by reflecting on the possible ways to construct a proof of the antecedent u ⊳ Q; he hypothesized that such a proof could always be presented as a well-founded tree governed by the following primitive inferences: 1. η-inference. If u ∈ Q, then Q bars u. 2. ϝ-inference. 4 If Q bars every immediate subnode uˆx of u, then Q bars u.
In other words, Brouwer believed that a proof of u ⊳ Q could always be tabulated into a proof of an alternative, inductive characterization of barhood u ◭ Q, defined relative to a spread S: One way to think of these trees is as a dialogue between an actor and a choice sequence α: at each step, the actor has either decided upon an answer (the η-inference), or asks the choice sequence what its next element is (the ϝ-inference), and continues to interact using that information.
If every proof of u ⊳ Q could in fact be tabulated into such a dialogue u ◭ Q (presented visually in Fig. 2), then it would be a simple matter to establish the uniform bound k by induction: 1. η-inference. We have u ∈ Q, so assign k = len( u). 2. ϝ-inference. By induction, we have for all possible extensions uˆx, a bound k x ; because F is a fan, there are only finitely many such extensions uˆx, so we simply choose k = max{k x | x}.
Theorem 1.11 (Soundness of inductive barhood). The inductive characterization of barhood is sound: if u ◭ Q is proved, then u ⊳ Q holds.
Proof We proceed by induction on the proof of u ◭ Q to prove that prove that u ⊳ Q.
1. η-inference. Then u ∈ Q, so we choose k = len( u). 2. ϝ-inference. By induction, we have uˆx ⊳ Q for all possible extensions x with a bound k; but this implies u ⊳ Q immediately, with bound k + 1.
In order to prove his fan theorem (and thence establish uniform continuity for real functions on the closed interval), Brouwer wished to prove a converse to Theorem 1.11: Proposition 1.12 (Brouwer's bar thesis). The inductive characterization of barhood is complete: if u ⊳ Q then u ◭ Q.

Functional programming interpretation: exceptions as shared secrets
It is possible to give an interpretation of Brouwer's bar thesis in terms of effectful functional programming in Standard ML, in the spirit of the "seemingly impossible functional programs" of Escardó (2007); Bauer (2006); Rahli et al. (2017). As we noted, a bar u ⊳ Q can be thought of as an operation that assigns to each infinite sequence α ≻ u a number k : N such that take(k, α) ∈ Q. Hence, we may represent such "functional bars" by a type of higher-order functions: type fun bar = (nat → nat) → nat On the other hand, an inductive bar can be represented in Standard ML by the following datatype of infinitely branching trees, in which the SPIT constructor encodes the η-inference and the BITE constructor encodes the ϝ-inference: datatype ind bar = SPIT of nat | BITE of (nat → ind bar) The argument of SPIT contains the number of steps that were necessary to reach the bar. Then, we may define an (effectful) algorithm to tabulate a functional bar Q : fun bar as a tree tabulate Q : ind bar, keeping track of the list of numbers xs : nat list we have received from BITE so far. The tabulation loop works in the following way: 1. If Q α = Q β gives the same answer for all α,β : nat → nat that start with xs, then we have reached the bar; therefore return SPIT. 2. Otherwise, we require at least another digit of information; call BITE, abstracting x:nat and recursing with xs := xs @ [x].
The first step is non-trivial, and we may accomplish it using a computational effect. Given a fresh exception E : exn, we may define the "generic infinite sequence" extending xs by indexing into xs and raising E when out of bounds: fun generic (E : exn) (xs : nat list) : nat → nat = fn i ⇒ List.nth (xs, i) handle Subscript ⇒ raise E The idea is that we may use the exception E as a shared secret in our tabulation loop 5 , to discover that Q has not yet converged and requires a further digit. The use of a computational effect in the Standard ML implementation of the tabulation is the essence of what is meant by Escardó's term effectful forcing (Escardó, 2013); indeed, the proof of our main result follows the moral arc of the code presented above, likewise hinging on the existence of a generic sequence that has the ability to "spy" on the internals of any function that calls it in the manner of a debug harness.

Relation to the bar thesis
Does the tabulate function terminate? The answer to this question depends entirely on what arguments Q : fun bar actually can be defined, which is in essence what Brouwer's bar thesis aims to control. Constructive mathematics is compatible with interpretations in which certain bizarre higher-order functions Q exist for which tabulate Q does not terminate; the most famous such case arises from the Kleene tree, an object that exists in the Church-Turing interpretation of second-order functions as first-order functions on codes (Troelstra & van Dalen, Dirk, 1988).

Perspective and contribution
Returning to the more modern perspective on constructive topology presented in Section 1.1, the bar thesis enunciated in Proposition 1.12 states that a certain constructive space B is completely determined by the topological space obtained from its points; but the spatiality of B, a classical triviality (Dummett, 2000), is independent of constructive mathematics.
Brouwer's "proof" of Proposition 1.12 was therefore not successful. Considering the Brouwer-Heyting-Kolmogorov interpretation of a proof of u ⊳ Q as a higher-order function, to accept Brouwer's bar thesis is to require that higher-order functions of a certain type can always be tabulated into well-founded trees or dialogues. Under the standard Church-Turing interpretation of higher-order functions, this tabulation is refuted (Troelstra & van Dalen, Dirk, 1988); far from a no-go theorem, this is in fact an invitation to consider alternative notions of computability that justify Brouwer's identification of higher-order functions (N → N) → N with inductive dialogues.
In this paper, we explain one possible notion of computability under which Brouwer's bar thesis is justified: definability in Gödel's System T. Our work is an extension of Martín Escardó's effectful forcing technique (Escardó, 2013), including a novel normalization theorem for certain interaction trees into Brouwer's (η, ϝ)-trees.

Formalization in Agda
The main results in this paper have been formalized in the Agda proof assistant (Norell, 2009). We carried out our proof in Martin-Löf's Intensional Type Theory extended by the function extensionality axiom, which was needed in order to prove the monad laws for Escardó's dialogue monad; we do not assume the unicity of identity proofs, and therefore our proof could in principle be converted to Cubical Agda (Vezzosi et al., 2019), in which function extensionality computes. Our formalization can be accessed as follows: 1. Browsable source: http://jonsterling.github.io/agda-effectful-forcing 2. Repository: http://www.github.com/jonsterling/agda-effectful-forcing 2 Gödel's System T In his famous Dialectica paper, Kurt Gödel introduced System T to serve as a formal theory of constructions for Heyting arithmetic (Gödel, 1958); in modern terms, T is a minimal, total functional programming language with function types σ ⇒ τ and a base type of natural numbers nat.
In the term for functional abstraction fn x ⇒ M, the variable x is bound; likewise, in the term for the recursor rec N [z ⇒ M z | s(x) with h ⇒ M s ], the variables x, h are both bound.
Convention 2.1 (Variable binding). In everything that follows, terms are considered modulo α-equivalence (i.e. up to permutations of bound variables), and we assume the ability to freely obtain a fresh variable that is not free in a term.

Static semantics of System T
The theory of System T is given by two forms of judgment: 1. Γ ctx asserts that Γ is a well-formed context. Contexts assign types to the free variables that are in scope. 2. Γ ⊢ M : σ asserts that M is a well-formed element of type σ in context Γ; this judgment is only defined when Γ ctx.
We omit definitional equality entirely, as our dialogue model will be too intensional to validate the usual equations of System T. 6 We do not need a separate judgment σ type, because all raw types σ generated by the grammar above are trivially well-formed. The rules for forming contexts are quite simple, and have the main role of preventing variable shadowing (a simplifying measure that will make semantic interpretation easier): The well-typed terms are generated by standard rules of inference; for instance, a variable x is well-formed if it appears in the context:

The function type
The elements of the function type σ ⇒ τ are characterized by an abstraction and an application rule. In our version of T, we have included just enough typing annotations in the syntax to guarantee the existence of a coherent interpretation of judgments Γ ⊢ M : σ into models; for this reason, we include a typing annotation on function application M @ σ N, but have no need for a typing annotation on abstraction fn x ⇒ M:

.2 Natural numbers and recursion
The natural numbers are given a unary encoding in our presentation of T, where z codes 0 and s(N) codes n + 1 if N codes n; a numeral n : N is therefore coded as the iterated application s n (z).
Programs on natural numbers in T are written by primitive recursion, at possibly higher type. 7 The recursor is typed as follows: The recursor should be thought of as a construct for defining a function F : nat ⇒ σ and then immediately applying it to the target N; in the case for the successor, one binds not only x : nat but also h : σ , which intuitively stands for F(x) (the induction hypothesis).

Programming in System T
To gain some intuition for higher-order primitive recursion, we work through some examples.
Convention 2.2 (Informal notation for T). In order to make our examples more clear, we impose some informal notation for terms.
The simplest example of programming using primitive recursion is given by the addition function: Another version of the addition function can be given that uses primitive recursion at higher type: 7 Sometimes the term primitive recursion is restricted to mean recursion at base type.
Higher-order primitive recursion is stronger than ordinary primitive recursion; for instance, Ackermann's function A : N × N → N is not primitive recursive, but we will see that it can be defined in T. 8 In T, Ackermann's function A is encoded by a program ack : nat ⇒ nat ⇒ nat that computes a function by recursion, as in Harper (Harper, 2016): where we define the n-fold iteration of a function as follows: The ability to use recursion to define functions of arbitrary order is the hallmark of System T.

Standard semantics of System T
In order to state what it means for a bar Q to be "realizable in System T", we must first explain the standard/Tarski-style semantics of System T, in which nat is interpreted by the ordinary set of natural numbers. We begin by defining the basic domains of interpretation, starting with contexts and types: σ is interpreted as a function from Γ to σ in the obvious way:   8 A three-parameter variant of Ackermann's function was discussed by Hilbert in his 1925 lectureÜber das Unendliche (Hilbert, 1926), later proved by Ackermann to not be primitive recursive (Ackermann, 1928).

System T-realizable bars
Every closed term · ⊢ F : (nat ⇒ nat) ⇒ nat determines, via the standard semantics above, an assignment of natural numbers F ⋄ T α : N to each sequence α : N → N: Using this notation, we are equipped to define a variation on u ⊳ Q that expresses realizability in System T, which we will write u ⊳ T Q:

Interactive semantics of System T
Martín Escardó pioneered a technique called "effectful forcing" for demonstrating non-constructive (Brouwerian) principles for the definable functionals of Gödel's System T (Escardó, 2013), including the continuity of functionals (N → N) → N and uniform continuity of functionals (N → 2) → N.
The idea of effectful forcing is to give a non-standard interactive model of System T in which an element of type nat is interpreted not as a single natural number, but as a kind of infinitely-branching well-founded tree with natural numbers at the leaves; the branch nodes of the tree represent queries to an oracle (a choice sequence). Escardó used this model to show that definable functionals in System T are always continuous; our contribution is to extend Escardó's method to prove that the realizable bars can be tabulated into Brouwer's (η, ϝ)-trees, establishing a restricted version of the bar theorem.
Intuitively, we would to arrange our interactive model in such a way that the naturals are interpreted quite literally as Brouwer's (η, ϝ)-trees, but it will be more clear to first interpret System T into a more flexible shape of tree (which we will call "Escardó dialogues"), in which queries to the choice sequence can be made out of order and repeated. Then, we prove that Brouwer's (η, ϝ)-trees can be construed as a normal form for the Escardó dialogues.

Escardó dialogues: ideal codes for functionals
Escardó's dialogue trees provide, for any sets I, J, A ∈ Set, a representation ETree(I, J, A) ∈ Set of computations of an element of A relative to an oracle of type I → J (i.e. an oracle that receives queries of type I and responds with answers of type J). The Escardó dialogues are generated by the following rules of formation: The Escardó dialogues exhibit an endofunctor Set → Set in the following way: In fact, the Escardó dialogues also have the structure of a monad, taking η(−) as the unit: The functor and monad laws for ETree(I, J, −) hold immediately by induction on dialogue trees; in the inductive step, however, we do need function extensionality.

Running Escardó dialogues
An Escardó dialogue a : ETree(I, J, A) may be executed on a function α : I → J to return a result a ⋄ E α : A as follows: The following two lemmas are due to Escardó (2013).
Proof Immediate by induction on the dialogue tree.
The following lemma is needed in Section 2.5 to establish the compatibility of the standard model of System T with the dialogue model defined below in Section 2.4.3.
Proof Immediate by induction on the dialogue tree.

The dialogue model of System T
We give an effectful call-by-name interpretation of System T, in which each type is interpreted as an algebra for the dialogue monad ETree(N, N, −), as suggested by one of the anonymous referees. The role of algebras here is the usual for effectful call-by-name semantics: a type is a set equipped with the capability to make queries to an oracle. Remark 2.6. The purpose of the algebra laws is to ensure that the action is compatible with the monadic structure of Escardó trees. For instance, the first law expresses that a "constant interaction" with the oracle that always returns a is taken to a; the second law ensures that interpreting a nested interaction is the same as interpreting each level of the interaction successively.
There is a forgetful functor U from algebras to sets taking an algebra A = (A, alg A ) to its carrier set U(A) = A.
Construction 2.7 (Free algebras). The forgetful functor has a left adjoint F that takes a set A to the free algebra F(A) whose carrier is the set of Escardó trees on A.
Construction 2.8 (Function algebras). Given a set A and an algebra B, we may define the function algebra A → B whose carrier set is the function set A → U(B); the algebra structure is obtained by applying alg B pointwise.
Construction 2.9 (Dependent product algebras). Likewise, given a set I and a family of algebras B (i∈I) , we may form the dependent product algebra ∏ i∈I B i in the same way.
Remark 2.10. In both Constructions 2.8 & 2.9, the verification of the algebra laws requires function extensionality -which we already needed to prove the monad laws for the dialogue monad.
The above is enough to define the interpretation of System T contexts and types Γ, σ into algebras ⟪Γ⟫, ⟪σ ⟫ as follows: 10 We may now define the interpretation of terms into the dialogue model:

Comparison with Escardó's interpretation. Our dialogue interpretation of
System T differs from that of Escardó, which fails to treat the recursor compositionally; Escardó interprets every type σ as a set ⟪σ ⟫, and then to interpret the recursor he must 10 It is worth noting that our interpretation of the natural numbers as the free algebra on the set N is somewhat bizarre from the standpoint of call-by-name semantics, where one expects the successor nodes to encapsulate an effect. However, as pointed out by one of the anonymous referees, one seems to disrupt the main result by employing the call-by-name natural numbers. define a lifting of the Kleisli extension to higher type by recursion on type structure: Then recursion at σ is interpreted by taking the lifted Kleisli extension ≫= σ of the recursor R(−) defined above. While this style of interpretation works fine, it is not compositional: the meaning of an expression should be determined in directly from the meaning of its subexpressions, but here we resorted to assigning a different meaning for the recursor at each type. Levy (2006) already suggests to resolve this problem by means of the algebra translation in Section 2.1 of his monograph on call-by-push-value, which leads to the more elegant account of recursion presented in this paper.

The generic point
In addition to the standard natural numbers (which are interpreted as "constant" trees, i.e. trees whose leaves are all labeled by the same numeral), the dialogue model of System T contains non-standard natural numbers that do not lie in the image of the interpretation function).
As a consequence of having non-standard numbers, the dialogue model also has nonstandard sequences; the most important of these sequences is called the generic point generic : U⟪nat ⇒ nat⟫, a special non-standard sequence that can be used to probe a higher-order function for its intensional structure, providing the main ingredient for the tabulation of higher-order functions as trees.
generic : U⟪nat ⇒ nat⟫ generic = λ n. n ≫= λ x. β(x; η(−)) Intuitively, by applying the dialogue interpretation of a functional · ⊢ F : (nat ⇒ nat) ⇒ nat to this generic point, we get a dialogue tree ⟪F⟫(generic) : ETree(N, N, N) that is precisely the trace of F's calls to its argument. Then, assuming that F witnesses u ⊳ T Q, we can compute the derivation of u ◭ Q by induction on this trace.
Lemma 2.11. The generic point commutes with dialogue execution in the sense that the following diagram commutes for all α : N → N: Proof Fixing n : U⟪nat⟫, one obtains α(n ⋄ E α) = generic(n) ⋄ E α immediately by induction on the dialogue tree n.

Compatibility of standard and interactive semantics
In order to use the generic point to tabulate a higher-order function · ⊢ F : (nat ⇒ nat) ⇒ nat into a dialogue tree, we will need to establish that the interactive semantics ⟪. . .⟫ and the standard semantics . . . are compatible at all types, in a sense that we must define. In essence, we will be using the fact that the dialogues in the image of the interpretation of System T encode pure functions, even though they coexist with "impure" functions. For intuition, it is worth considering what it would mean for the two interpretations to be compatible at the base type nat. In this case, we would want to ensure for any term · ⊢ M : nat, that M is the same as ⟪M⟫ ⋄ E α for all sequences α : N → N: In order to prove the above, however, we cannot simply proceed by induction on the syntax of System T -the induction hypothesis will not be strong enough when we pass underneath a binder; the compatibility condition we have stated in in fact a closure property of the entire language that must be established at all higher types simultaneously, a situation that calls for logical relations (Tait, 1967).
Tait's method of logical relations is a tool to endow a property of terms at base type with a hereditary action on all higher types. In our case, we will extend the property of "having compatible standard and dialogue interpretations" from nat to all types σ , and then show that the resulting structure is closed under all the constructors of System T.

A logical relation between the two models
We begin by defining the main constituents of a logical relation between − and U⟪−⟫. For each point α : N → N, we will define an interpretation of each type σ as a relation between σ and U⟪σ ⟫ that expresses the hereditary compatibility of the standard interpretation with the execution of the dialogue interpretation at α.
.iven s : σ and s : U⟪σ ⟫, we will define the following predicate by recursion on the type σ : Likewise, we may define an analogous relation on contexts and environments as follows, given g : Γ and g : U⟪Γ⟫: Theorem 2.12 (Fundamental theorem). Fix a point α : N → N and let Γ ⊢ M : σ be a term of System T; then for all g : Γ and g : U⟪Γ⟫ such that α Γ ∋ g ∼ g, we have α σ ∋ M g ∼ ⟪M⟫g.
Proof By induction on Γ ⊢ M : σ , using the monad axioms, the algebra axioms, and Lemmas 2.3 and 2.4.

Tabulating realizable bars into Escardó dialogues
Fixing a monotone subset Q ⊆ list(N), our goal has been to show that u ◭ Q follows from u ⊳ T Q, recalling the definition of the latter: Using the results of the previous section, we are now equipped to prove an intermediate theorem that tabulates any System T-realizable bar into an Escardó dialogue, in the sense that u ⊳ T Q implies u ◭ E Q, defined below: ( u ◭ E Q) ∃n : ETree (N, N, N). ∀α : N → N. u + + take(n ⋄ E α, α) ∈ Q It is here that we make use of the generic point generic : U⟪nat ⇒ nat⟫ in a critical way.
Theorem 2.13 (Tabulation of realizable bars). If u ⊳ T Q then u ◭ E Q.
Proof We abbreviate σ (nat ⇒ nat) ⇒ nat. Suppose u ⊳ T Q, i.e. we have some term · ⊢ F : σ such that u + + take(F ⋄ T α, α) ∈ Q for all α : N → N. Interpreting F into the dialogue model, we have F ⟪F⟫ : U⟪σ ⟫; instantiating with the generic point, we therefore obtain a single Escardó dialogue F(generic) : U⟪nat⟫.
Using F(generic) as our witness to u ◭ E Q, we fix α : N → N to verify that Q contains the list u + + take(F(generic) ⋄ E α, α). Recalling our assumption, it would suffice to verify that F ⋄ T α = F(generic) ⋄ E α.
By the fundamental theorem (Theorem 2.12), we already have α σ ∋ F ∼ F. Unfolding the logical relation explicitly this amounts to the fact that F (β ) = F(b) ⋄ E α for all α nat ⇒ nat ∋ β ∼ b; we note that F (β ) = F ⋄ T β . Choosing β = α and b = generic, it therefore remains only to show that α nat ⇒ nat ∋ α ∼ generic. We fix α nat ∋ n ∼ n to show that α nat ∋ α(n) ∼ generic(n), which is the same as to say α(n) = generic(n) ⋄ E α. But this is immediate by Lemma 2.11.

Brouwerian dialogues: a normal form for Escardó Dialogues
In the previous section, we showed that a System T-realizable bar can be tabulated into an Escardó dialogue: in other words, u ◭ E Q follows from u ⊳ T Q. In this section, we bridge the gap between the Escardó dialogues and Brouwer's (η, ϝ)-trees, by proving that the latter express a normal form for the former with respect to permutation, omission, and repetition of queries to the choice sequence.

Ephemerality, the essence of Brouwerian dialogues
The content of Brouwer's purported (but failed) proof of his bar thesis was to assert that one can tabulate the evidence for barhood into a well-founded mental construction (van Atten, 2004;Dummett, 2000); Escardó's translation of System T terms into dialogue trees is essentially a formalization of Brouwer's insight.
However, Escardó's dialogues differ from Brouwer's mental constructions of barhood (which are captured precisely by the judgment u ◭ Q) in one crucial respect: whereas Escardó's trees branch on an arbitrary query to the ambient choice sequence, queries in Brouwer's mental constructions must be made in order, i.e. with respect to the current moment in ideal time; as such, the Brouwerian dialogues are ephemeral-with each query, the head of the ambient choice sequence is consumed and the remainder of the dialogue is interpreted with respect to the tail of the choice sequence.
Our task, then, will be to normalize Escardó's dialogues into Brouwer's ephemeral mental constructions, and then show how to massage these into a derivation of u ◭ Q. Just as we showed how to execute an Escardó dialogue against a choice sequence, we can do the same for the Brouwerian (ephemeral) version. For a : BTree(J, A) and α : N → J, we define a ⋄ B α : A by recursion on a as follows:

Barhood relative to Brouwerian dialogues
Just as we have defined u ◭ E Q as a notion of barhood witnessed by an Escardó dialogue, we now do the same for Brouwerian dialogues, recalling the definitions of barhood we have given so far: (N, N, N). ∀α : N → N. u + + take(n ⋄ E α, α) ∈ Q ( u ◭ B Q) ∃n : BTree (N, N). ∀α : N → N. u + + take(n ⋄ B α, α) ∈ Q The Brouwerian dialogues that we have defined are nothing but representations of proofs of u ◭ Q, as the following lemma shows. Proof Fixing Q and u such that u ◭ B Q, we therefore have some Brouwerian dialogue n : BTree (N, N) such that for all sequences α, we have u + + take(n ⋄ B α, α) ∈ Q. We proceed by induction on n to prove u ◭ Q, using the fact that Q is monotone.

Normalizing Escardó dialogues into Brouwerian dialogues
We wish to normalize elements of ETree(N, J, A) (Escardó dialogues) into elements of BTree(J, A) (Brouwerian dialogues) in a way that commutes with execution. To do so, we design an inductive/proof-theoretic characterization of the normalizable Escardó dialogues, and then show that all Escardó dialogues can be coded as such. This yields a constructive and structurally recursive normalization algorithm. To this end, we define below two mutually inductive forms of judgment, whose rules are given in Fig. 3: 1. u a a, presupposing u : list(J) and a : ETree (N, J, A), and guaranteeing a : BTree(J, A), means that the Escardó dialogue a normalizes to the Brouwerian dialogue a. For the sake of intuition, we provide an implementation of the algorithm in Standard ML in Fig. 4; the mathematical version given in this section can be seen as a specification and termination proof for the Standard ML program.

Explanation of algorithm
Normalization occurs with respect to a node u that is extended every time a ϝ node is inserted; u should be thought of as the "current known prefix of the choice sequence". To normalize an Escardó dialogue a over a node u, one proceeds by case: if a = η(a) then it is already normal; on the other hand, if a = β(i; b), then it is necessary to find out what the ith element of the choice sequence is.
If i < len( u), then we have already "cached" this query in u i , and we therefore proceed by normalizing b( u i ); on the other hand, if i ≥ len( u), we must continue to insert ϝ-queries until we have information about the ith element of the choice sequence. Locating "cached" information and inserting new queries is the role of the u | i a ≪ v a judgment.
Lemma 3.2. The inductive characterization of normalization u a a in Fig. 3 is functional, i.e. for any u : list(J) and a : ETree (N, J, A) there is a unique a : BTree(J, A) such that u a a.  datatype ('i, 'j, 'a) etree = RET of 'a | QUERY of 'i * ('j → ('i, 'j, 'a) etree) datatype ('j, 'a) btree = SPIT of 'a | BITE of ('j → ('j, 'a) btree) fun norm us (RET a) = SPIT a | norm us (QUERY (i, k)) = normQ us i k us and normQ us Z k [] = BITE (fn u ⇒ norm (us @ [u]) (k u)) | normQ us Z k (v :: ) = norm us k v | normQ us (S i) ( :: vs) = normQ us i k vs | normQ = raise Subscript Fig. 4. A Standard ML implementation of the dialogue normalization algorithm whose graph is specified in Fig. 3.
Proof In fact, we must simultaneously establish the functionality of u a a and u | i b ≪ v b. The existence part of functionality follows by simultaneous induction on a, v, and i; the uniqueness part follows immediately by inspection of the generating rules. Lemma 3.4 (Coherence of normalization and execution). Execution of Brouwerian dialogues is compatible with normalization, as defined in Corollary 3.3; to be precise, the following diagram commutes for all u : list(J) and α : N → J.
When u = , this becomes the statement that a ⋄ E α = norm (a) ⋄ B α for any dialogue a.
Proof By induction on the graph of the normalization function.

Validity of the bar thesis for T-realizable bars
We obtain the main theorem of this paper as a corollary to the constructions of the past several sections. The bar thesis for System T states that for any monotone set Q ⊆ list(N) of nodes, the inductive definition of barhood is complete in the sense that we can conclude ◭ Q from ⊳ T Q.

Theorem 4.1 (The bar thesis for realizable bars). Brouwer's bar thesis holds for bars that are realizable in System T: for any monotone subset Q
Proof Supposing ⊳ T Q, we need to construct ◭ Q; by Lemma 3.1, it is enough to show that ◭ B Q, i.e. exhibit some n : BTree(N, N) such that for all α : N → N, we have take(n ⋄ B α, α) ∈ Q. On the other hand, by Theorem 2.13 we already have ◭ E Q, from which we obtain some n : ETree(N, N, N) such that for all α : N → N, we have take(n ⋄ E α, α) ∈ Q. Therefore, choosing n = norm (n), all that remains is check that take(norm (n) ⋄ B α, α) = take(n ⋄ E α, α). But norm (n) ⋄ B α = n ⋄ E α by Lemma 3.4.

The Bar Induction principle
The essence of Brouwer's bar thesis lies in the tabulation of a proof of u ⊳ Q into a proof of u ◭ Q. In constructive metamathematics, however, an equivalent presentation of the Bar Thesis as an induction principle is usually considered: Proposition 5.1 (Monotone Bar Induction). For any subset R ∈ list(N) and a monotone bar ⊳ Q, we can conclude ∈ R from the following conditions: To prove the equivalence of Proposition 5.1 with our formulation of Brouwer's bar thesis on monotone bars (Proposition 1.12), we begin by verifying that it suffices to consider unqualified barhood of the root node . In this section we write v u to mean that u = v + + w for some w; this notation is the reverse of Dummett's (2000), but we find it more concrete.
Lemma 5.2 (It suffices to consider the root). If ⊳ Q =⇒ ◭ Q for all monotone Q, then u ⊳ Q =⇒ u ◭ Q for all u and monotone Q.
⊳ Q immediately, whence ◭ Q follows by assumption. To see that u ◭ Q ′ follows from ◭ Q, we observe that the latter can be obtained immediately as a subtree of the former.

Theorem 5.3. Monotone Bar Induction (Proposition 5.1) is equivalent to Brouwer's Thesis on monotone bars (Proposition 1.12).
Proof (⇒) Suppose that Proposition 5.1 holds; by Lemma 5.2, it suffices to show that ◭ Q follows from ⊳ Q. We choose a motive of bar induction based on our goal, namely R { u | u ◭ Q}.
1. Base case. Fixing u ∈ Q, we need to see that u ◭ Q; this is just the η-inference. 2. Inductive step. Suppose that uˆx ◭ Q for all x; we conclude u ◭ Q by the ϝinference.
(⇐) Suppose that Proposition 1.12 holds. Fix a monotone bar ⊳ Q and a subset R ⊇ Q such that u ∈ R follows from ∀x. uˆx ∈ R for all u, to show that ∈ R. By Proposition 1.12, we have ◭ Q; we proceed by induction, generalizing to conclude v ∈ R from v ◭ Q for all v: x, whence by assumption we have v ∈ R.

Monotonicity, decidability, and continuity
We have focused exclusively on monotone subsets Q ⊆ list(N), i.e. collections of basic observations that are closed under extension; intuitively, such a bar is one that cannot be "escaped". However, another variant of the bar thesis that concerns decidable subsets has received more attention in the literature. A subset Q ⊆ list(N) is decidable when ∀ u. u ∈ Q ∨ u ∈ Q holds; of course, this is classically true for every subset Q, but in constructive logic, it doesn't necessarily hold for all Q.
The bar induction principle for decidable bars is weaker than monotone bar induction (Proposition 5.1); in essence, this is because any decidable bar can be completed into a monotone bar (Dummett, 2000).

Lemma 5.4. Any decidable bar ⊳ Q can be freely completed into a monotone decidable bar
Proof The inclusion of the discrete poset of lists of natural numbers into the poset of lists with the approximation ordering u + + v u induces a contravariant reindexing from monotone subsets into general subsets. This reindexing has both left and right adjoints, by Kan extension. In particular, the left adjoint takes a general subset Q and transforms it into a monotone subset First we observe that the transformation described above preserves the decidability of the bar: to decide u ∈ Q ♮ , one simply decides v ∈ Q for as many prefixes v u as necessary. Second, we check that ⊳ Q ♮ assuming ⊳ Q. Fixing α : N → N, we need some k : N such that take(k, α) ∈ Q ♮ . But Q is a bar, so we already have k such that take(k, α) ∈ Q, from which we immediately obtain take(k, α) ∈ Q ♮ .
Theorem 5.5. Decidable bar induction follows from monotone bar induction.
Proof We fix a decidable bar ⊳ Q and an inductive superset R ⊇ Q, to show that ∈ R. By Lemma 5.4, we have a monotone decidable bar Q ♮ ; following Dummett (2000), we apply monotone bar induction on Q ♮ , choosing the motive S R ∪ Q ♮ . We clearly have the base case Q ♮ ⊆ S; to see that S is inductive, we assume that ∀x. uˆx ∈ S, to show that u ∈ S. Because Q ♮ is decidable, we can proceed by case: 1. If u ∈ Q ♮ , then we immediately have u ∈ S. 2. If u ∈ Q ♮ , then our only option is to check that u ∈ R. Using the inductiveness of R, it suffices to verify that uˆx ∈ R for all x. By assumption, we have uˆx ∈ S; we proceed by case on whether uˆx ∈ Q ♮ : a. Suppose uˆx ∈ Q ♮ ; because u ∈ Q ♮ , we know that no prefix of u is in Q, so therefore we must have uˆx ∈ Q. Because Q is a subset of R, we are done. b. Suppose uˆx ∈ Q ♮ ; because we have assumed uˆx ∈ S, we therefore already have uˆx ∈ R.
Under a further continuity principle, which Escardó (2013) has shown to be validated for T-definable functionals, monotone and decidable bar induction are in fact equivalent (Dummett, 2000;Troelstra & van Dalen, Dirk, 1988).

Schwichtenberg's closure theorem
In 1979, Schwichtenberg proved an even stronger result than what we have proved here, namely that for any closed System T term that codes a bar of type 0 and 1, the bar recursor can already be defined in T (Schwichtenberg, 1979). In more recent work, Oliva and Steila give an elegant and direct proof of Schwichtenberg's result (Oliva & Steila, 2018). It should be possible to replicate this result in our setting by using Church encodings of dialogues, which Escardó has used to exhibit the modulus of continuity of a T-definable functional as a program in System T (Escardó, 2013).
The results of Schwichtenberg, Oliva and Steila, Escardó, Xu, and ourselves are part of long tradition of comparing formal definability with continuity and bar induction principles, initiated by Kreisel & Troelstra (1970) in a pioneering tour de force that clarified the closure conditions enjoyed by neighborhood functions (functions that correspond to Brouwer's inductive bars).

Bar recursion and continuous moduli
Whereas bar induction is a principle of logic (a method to obtain proofs), bar recursion is an principle of mathematical construction (a method to define functions) proposed by Spector (1962). In results obtained subsequent to those described in our own paper, Fujiwara & Kawai (2019) show that bar induction for decidable bars is equivalent to the existence of a bar recursor for every functional of type (N → N) → N that has a continuous modulus of continuity. This result is closely related to that of Schwichtenberg (1979), as well as those of Escardó and ourselves, considering Escardó's proof that every definable such functional in System T has a definable modulus of continuity -and hence a continuous modulus of continuity (Escardó, 2013).
In other recent work, also obtained subsequent to our results, 11 Xu has extended Escardó's methods to achieve a monadic translation of System T into itself parameterized in a monad; Xu's result includes an elegant algorithm to obtain both moduli of continuity and bar recursors of System T programs (Xu, 2020a,b).

5.5
Martin-Löf's analysis of Π 1 1 sentences In his doctoral dissertation, Per Martin-Löf pursued an explanation of constructive meaning in which Π 1 1 sentences ending in a decidable predicate are defined to be canonically verified by (η, ϝ)-trees as envisioned by Brouwer (Martin-Löf, 1970). A Π 1 1 sentence is one of the form ∀α i : S i . ∃β j : T j . P α i . . . β i , in which S i , T i are types of order at most 1; the statement that some decidable subset Q is a bar is an example of such a sentence, but Martin-Löf's insight was that one might as well consider all such sentences as being about bars.
In contrast to the Brouwer-Heyting-Kolmogorov (BHK) interpretation of Intuitionistic logic, Martin-Löf did not at the time consider every well-formed sentence generated from ∀, ∃, ∨, ∧, ⊃, ¬, P to be constructively meaningful; rather, he argued that different kinds of sentences needed to be analyzed individually and interpreted, in order to be endowed with constructive meaning. This hesitant and open-ended perspective on constructive meaning is in fact much closer to Brouwer's views than the perhaps infelicitously named BHK interpretation -an interpretation that, in generality, fails to verify Brouwer's thesis on bars (which might as well be called "Brouwer's thesis on Π 1 1 sentences").
Exhibiting a theory of meaning that is at once compatible with both the BHK interpretation and Brouwer's interpretation of Π 1 1 sentences is a difficult matter, and leads inevitably to forcing -both sheaf-theoretic and effectful. The subject of this paper is to explain one possible BHK-compatible theory of meaning that also validates Brouwer's thesis, but we must admit that realizability in System T is too formalistic a constraint to be realistic.

Operational forcing
A forerunner of Escardó's effectful forcing can be found in Coquand and Jaber's A computational interpretation of forcing in Type Theory (2012); unlike effectful forcing, which is a purely denotational construction, Coquand and Jaber give an operational interpretation of System T extended by an oracle f : nat ⇒ bool, and use it to show that the definable functionals on sequences of booleans are uniformly continuous.
Using similar ideas, Coquand & Mannaa (2016) have constructed a countermodel to Markov's principle for dependent type theory from an operational perspective, adding a new constant f : nat ⇒ bool to the language. In order to specify the equational behavior of the generic point f, the judgments of the type theory are indexed in a forcing condition p that specifies a finite subgraph of a sequence of booleans. Then, two conditions are imposed: 1. The judgments of type theory must be monotone with respect to approximations of forcing conditions. 2. The judgments of type theory must be local with respect to coverings of forcing conditions: roughly, if the judgment J holds at each leaf of an (η, β) tree rooted at p, then J holds at p.
The locality condition above has the result of rendering the semantic evidence of the judgments of the forcing extension into (η, β) trees; this is to be contrasted with the denotational style of effectful forcing, in which the terms themselves are interpreted as (η, β) trees (potentially at higher type). This is concordant with the usual differences between operational and denotational approaches to semantics.

Forcing in Nuprl
Nuprl is one of the oldest implementations of dependent type theory, inspired by the ideas of Bishop, De Bruijn, Martin-Löf, and Scott (Constable et al., 1986). In contrast to the algebraic tradition of type theory, in which the sound and complete interpretation of a formal language into a suitable class of models is emphasized, Nuprl is based on the idea of considering a single intended model, whose properties are meant to approximate the limitations of human mental construction.
Over the years, the designers of Nuprl have increasingly emphasized the validity of nonconstructive but computationally justified principles in their evolving computational model, including type-theoretic variants of Markov's principle, bar induction, and Brouwer's continuity theorems Rahli & Bickford, 2016;Rahli et al., 2017). The validity of Markov's principle and bar induction in Nuprl followed roughly from the fact that Nuprl's computational semantics had been developed in a classical metatheory, in which these principles already hold. At a high level, the classical metatheory of the operational model allowed termination properties of programs to be established using classical logic.
Finding this state of affairs unsatisfactory, researchers working on Nuprl have recently developed a new constructive semantics based on forcing (Bickford et al., 2018), in a manner that generalizes the forcing conditions of Coquand & Mannaa (2016) to include finite data about an unbounded collection of choice sequences. The resulting Nuprl system can be seen as a synthesis of Brouwer's purely denotational understanding of constructive meaning with the operational approach to constructivity pioneered by Martin-Löf in his influential report, Constructive Mathematics and Computer Programming (1979).

Relation to sheaf models
The operational account of forcing extensions of type theory described above is tantalizing close to the notion of a sheaf model over a topological space (such as the space of sequences of naturals or booleans). While it was perhaps unclear at the time, due to the highly unfolded character of the constructions, this connection can be rationalized in the following way: the extended operational model of Coquand and Mannaa is, at a high level, just the standard operational model of dependent type theory carried out internally to the topos of sheaves on Cantor space. A similar statement should be true of the operational model of Nuprl's forcing extension (Bickford et al., 2018).
More recently, Sterling & Harper (2018) have developed an analogous construction of a different forcing extension of type theory for guarded recursion, utilizing the internal language of another sheaf topos to express the operational semantics and relational interpretation of the judgments of type theory.

Denotational forcing
The main ideas underlying our proof of Brouwer's bar thesis for T-realizable bars were invented by Escardó in his paper Continuity of Gödel's System T definable functionals via effectful forcing (Escardó, 2013). Escardó used the effectful forcing technique to prove a related property of T-definable functionals F : (N → N) → N, namely continuity: ∀α. ∃k. ∀β . take(k, α) = take(k, β ) =⇒ F(α) = F(β ) The proof of this fact, being constructive, contains an algorithm to compute this modulus of continuity k from each sequence α.
Relative to Escardó, we have shown that the same method can be used to validate a restricted version of Brouwer's bar thesis, contributing a novel normalization theorem for Escardó's non-canonical (η, β)-trees into Brouwer's canonical (η, ϝ) trees. Unlike Escardó, who developed effectful forcing for a version of System T extended by an oracle, we have avoided adding the oracle to the syntax, following a suggestion from Vincent Rahli; finally, following a suggestion from one of the anonymous referees, we have achieved a more compositional dialogue interpretation.

Syntactic forcing translations
Recently a number of researchers have investigated forcing extensions of the Coq proof assistant and its calculus of inductive constructions, further clarifying the connection between forcing, computational effects, and parametricity Jaber et al., 2016;Pédrot & Tabareau, 2017;Pédrot & Tabareau, 2019). Coq's forcing apparatus differs from that of Nuprl in a couple important ways.
First, forcing over an arbitrary preorder is supported, whereas Nuprl has been hard-coded for a specific forcing extension. On the other hand, Nuprl's forcing is localized in the sense that one may amalgamate objects defined on a bar, in essence a sheaf condition; the local character of the Nuprl semantics is very important, as it is the main ingredient to justifying the bar induction principle in the forcing extension.
Second, the consistency of Coq's forcing extension is justified by purely syntactical means through a simple translation into the base calculus. In contrast, Nuprl's forcing extension is justified by means of a completely new version of the partial equivalence relation semantics in which monotonicity and local character conditions are fully unfolded a la Coquand & Mannaa (2016) rather than treated abstractlyà la Sterling & Harper (2018), an enormous undertaking that took multiple years.

Sheaf-theoretic forcing
An arguably more direct approach to obtain the compatiblity of type theories with Brouwerian principles such as bar induction and continuity is to consider the petit topos of sheaves on a suitable space (such as Baire space or Cantor space), or the gros topos of sheaves over a suitable category of test spaces (Fourman, 1984).
In his doctoral thesis, Xu (2015) considers sheaf models of dependent type theory validating uniform continuity and the fan theorem. There is an apparent difficulty modeling type theoretic universes in sheaves, which some authors have erroneously located in the fact that the amalgamation of a family of types defined at the leaves of a bar is unique only up to isomorphism (Xu & Escardó, 2016), or in the apparent impredicativity of certain classic constructions of sheafification (Xu, 2015).
In fact, universes of sheaves are known to be unproblematic (Streicher, 2005), and sheafification is entirely compatible with predicative foundations (Awodey et al., 2009); the real location of the difficulty pointed out by Xu and Escardó is that known constructions of sheafification do not preserve the choice of codes for type connectives on the nose, so the strict reduction rules that identify El(Â→B) with El(Â) → El(B) must be weakened to canonical isomorphisms.
These difficulties motivated Coquand et al. (2017) to consider models of type theory in stacks, which express descent from a bar in a weak enough fashion that universes can be modeled without sheafification. The stack model of type theory contains a universe that classifies discrete types (types with no higher-dimensional structure), and has been used to give a purely denotational account of the independence of Martin-Löf's type theory from Markov's principle.