Sheaves as oracle computations

In type theory, an oracle may be specified abstractly by a predicate whose domain is the type of queries asked of the oracle, and whose proofs are the oracle answers. Such a specification induces an oracle modality that captures a computational intui…

Authors: Danel Ahman, Andrej Bauer

Sheaves as o racle computations Danel Ahman # Ñ  Institute of Computer Science, Universit y of T artu, Estonia Andrej Bauer # Ñ  F acult y of Mathematics and Physics, Univ ersity of Ljubljana, Slo venia Institute of Mathematics, Physics and Mec hanics, Slov enia Abstract In t yp e theory , an oracle ma y b e sp ecified abstractly by a predicate whose domain is the t yp e of queries ask ed of the oracle, and whose pro ofs are the oracle answers. Suc h a specification induces an oracle mo dality that captures a computational in tuition ab out oracles: at each step of reasoning w e either know the result, or w e ask the oracle a query and pro ceed up on receiving an answer. W e c haracterize an oracle mo dality as the least one forcing the given predicate. W e establish an adjoint retraction b et w een modalities and prop ositional con tainers, from which it follo ws that every modality is an oracle mo dality . The left adjoint maps sums to suprema, whic h makes suprema of modalities easy to compute when they are given in terms of oracle modalities. W e also study shea ves for oracle mo dalities. W e describ e sheafification in terms of a quotient-inductiv e type of computation trees, and describ e shea v es as algebras for the corresponding monad. W e also introduce equifoliate trees, an in tensional notion of oracle computation given by a (non-prop ositional) container. Equifoliate trees descend to sheav es, and lift from sheav es in case the container is projective. As an application, w e give a concrete description of all Lawv ere-Tierney top ologies in a realizability top os, closely related to a game-theoretic characterization by T akayuki Kihara. 2012 ACM Subject Classification Theory of computation → Mo dal and temp oral logics Keyw o rds and phrases mo dality , oracle, sheaf F unding Danel A hman : This work was supported by the Estonian Research Council grant PR G2764. A ndr ej Bauer : This material is based up on work supp orted by the Air F orce Office of Scientific Researc h under a w ard n um ber F A9550-21-1-0024. A ckno wledgements W e thank T aka yuki Kihara, Andrew Swan, and Sewon P ark for enlightening discussions. 1 Intro duction Shea v es are a fundamental notion in several branches of mathematics, notably in geometry and algebra, as well as in logic. They are less frequently pursued from the computational p oin t of view, whic h is the topic of our pap er. Our starting p oint is the definition of an or acle mo dality , which captures the intuition that reasoning relative to an oracle pro ceeds b y asking the oracle to provide evidence of statemen ts that w e cannot prov e constructively , for instance, the decidability of the halting of a given T uring machine. In Section 3 we provide inductive and fixed-p oint constructions of oracle mo dalities, and sho w that they are characterized as the least mo dalities forcing the sp ecifying predicate. After relating oracle mo dalities to instance reducibilit y in Sections 3.1 and 3.2, w e show in Section 3.3 that the oracle mo dality construction is a functor from the category of prop ositional containers to the frame of mo dalities. Not only that, the functor has a section, which is also its righ t adjoint, from which it follo ws that ev ery La wvere-Tierney top ology [19] is in fact an oracle mo dality . Encouraged by the generality of our approach, in Section 4 we pass from mo dal pro ofs to mo dal constructions. An element of a t yp e X constructed relative to an oracle is an elemen t of the she afific ation of X , which w e describ e in Section 4 as a quotient-inductiv e 2 Sheaves as oracle computations t yp e. The inductive part provides a computational view of constructions relative to an oracle, where again at each step we either know an element of X or we ask the oracle a question. Ho w ever, this view is of limited v alue b ecause the quotien t masks intensional information ab out the computation, suc h as which queries are asked in the construction. W e thus pro vide in Section 4.2 a second description of sheafification in terms of e quifoliate tr e es . They capture in tensional information one normally exp ects when studying effectful computations, b ecause they are ordinary , unquotiented inductive trees built from an arbitrary , p ossibly non-prop ositional container, constrained to compute at most one element up to mo dal equalit y . W e prov e that equifoliate trees form a monad, they descend to the sheafification for the asso ciated prop ositionally truncated container, and when the container is pro jectiv e, sheafification lifts to equifoliate trees. As an application, in Section 5 we c haracterize all La wvere-Tierney top ologies in a relative realizabilit y top os in terms of oracle mo dalities. W e give tw o explicit descriptions, one in terms of realizers enco ding oracle computation for a predicate on a partitioned assembly , and another for an extended W eihrauch predicate. The description is closely related to a recent game-theoretic treatmen t of Lawv ere-Tierney top ologies by T aka yuki Kihara [16]. 2 T yp e-theo retic background F or the majority of the pap er, we will work in what is essen tially the underlying t yp e theory of Ro cq, i.e., the Calculus of Inductive Constructions (CIC) [ 23 ]. Sp ecifically , we ha v e dep enden t pro ducts Π ( x : A ) . B ( x ) , dep endent sums Σ ( x : A ) . B ( x ) , the identit y type, which w e write as equality a = b , as w ell as inductive types with dep endent elimination. F or instance, we resp ectively write 2 and N for the standard inductive types of b o oleans and natural num b ers. CIC has an infinite cumulativ e hierarch y of (predicative) t yp e universes T yp e 0 : T yp e 1 : · · · whic h do es not play a central role in our developmen t. W e just work at an y chosen level T ype i , whic h we simply write as T ype . In sev eral places we rely crucially on ha ving an impr e dic ative univ erse Prop of prop ositions, i.e., one that allows quantification ov er arbitrary t yp es. F or b etter readability , w e use logical notation ∀ , ∃ , ⇒ , ⇔ for constructions in Prop and the type-theoretic one Π , Σ , → , ↔ for op erations on types. Note that Prop is pro of-irrelev ant, i.e., from prop ositions we may eliminate only to prop ositions, and not to general types. In particular, from a pro of of ∃ x : A. P x w e cannot in general extract an a : A suc h that P a . Additionally , we assume the follo wing principles, which are v alid in top oses: function extensionality : functions giving equal v alues are equal, pr op ositional extensionality : if p, q : Prop and p ⇔ q , then p = q , uniqueness of pr o ofs : if p : Prop and u, v : p , then u = v , definite description : if ∃ ! x : A. P x then we hav e a : A such that P a . Here ∃ ! x : A. P x is the usual shorthand for ∃ x : A. ( P x ∧ ∀ y : A. ( P y ⇒ x = y )) which expresses unique existence. A consequence of definite description is unique choic e : if P : A → B → Prop and ∀ x : A. ∃ ! y : B . P x y then we hav e f : A → B suc h that ∀ x : A. P x ( f x ) . An y further extensions of type theory , such as quotient-inductiv e types used in Section 4, are discusses explicitly when used. Muc h of our developmen t can b e b est framed in terms of containers [ 1 ], also known as univ ariate p olynomials [ 13 , 21 ]. Recall that a c ontainer A ◁ P comprises a t yp e A of shap es and a type family P : A → T ype of p ositions . Originally developed to mo del parametric data types and p olymorphic functions, o v er time containers ha v e found applications in D. Ahman and A. Bauer 3 man y other areas of computer science and mathematics. They form a category Cont , with a morphism t ◁ q : A ◁ P → B ◁ Q giv en by maps t : A → B and q : Π ( a : A ) . Q ( t a ) → P a . W e shall mainly work with pr op ositional c ontainers , which are containers whose families of p ositions are predicates P : A → Prop . Prop ositional containers form a full sub category PCont of Cont . W e usually refer to a prop ositional container A ◁ P just b y its predicate P . 3 Oracle mo dalities W e take a mo dality to b e a monad on Prop qua category , i.e., a map j : Prop → Prop that is monotone: ∀ ( p q : Prop ) . ( p ⇒ q ) ⇒ ( j p ⇒ j q ) , inflationary: ∀ p : Prop . p ⇒ j p , and idemp oten t: ∀ p : Prop . j ( j p ) ⇒ j p , also kno wn as a L awver e-Tierney top olo gy [18], a lo c al op er ator [30], and a nucleus [15]. Ev ery mo dality preserves conjunctions, ∀ ( p, q : Prop ) . j ( p ∧ q ) = j p ∧ j q . Mo dalities form a frame Mo d [ 15 , §2.5] with resp ect to the p oint wise ordering j ≤ k : ⇔ ∀ p : Prop . ( j p ⇒ k p ) . An (abstr act) or acle is sp ecified by a predicate P : A → Prop , where we think of an elemen t a : A as a query which the oracle answers by providing evidence of P a . In the in teresting cases the oracle so specified cannot b e shown to exist constructiv ely , i.e., ∀ a : A. P a is not pro v able. Nevertheless, we would still like to reason as if it were. ▶ Example 3.1. The excluded middle oracle lem : Prop → Prop is given by lem p := p ∨ ¬ p . ▶ Example 3.2. The Limite d Principle of Omniscienc e (LPO) [ 7 ] states that every infinite binary sequence either contains 1 or is constantly 0 . The oracle corresponding to it is sp ecified b y the predicate lp o : 2 N → Prop , defined as lp o α := ( ∃ n. α n = 1) ∨ ( ∀ n. α n = 0) . Other instances of excluded middle can b e devised in a similar fashion. ▶ Example 3.3. A traditional oracle in computabilit y theory decides membership in a subset S ⊆ N . In our setting, suc h an oracle is sp ecified b y a predicate S : N → Prop , whic h induces the mem bership predicate mem S : N → Prop defined by mem S p := S p ∨ ¬ S p . ▶ Example 3.4. If P : A → Prop sp ecifies an oracle whic h is implemented by f : ∀ a : A. P a , then no additional computational p ow er is gained b y ha ving an oracle, as we can replace it with f . In Example 3.3 this happ ens when S is decidable. ▶ Example 3.5. The other trivial case arises when P : A → Prop has a coun terexample a : A so that ¬ P a . In this case, the oracle gets stuck on the query a b ecause P a has no answer. In tuitiv ely sp eaking, to sho w that s : Prop holds relative to an oracle sp ecified by P : A → Prop w e may either establish s without consulting the oracle, or ask the oracle a query a : A and, up on receiving evidence u : P a , pro ceed recursively . Even tually we must stop querying the oracle and resolve s with the accumulated knowledge ab out P . The in tuition is captured b y the or acle mo dality o P : Prop → Prop , defined at s : Prop inductively by the clauses p rf : s → o P s , ask : Π ( a : A ) . ( P a → o P s ) → o P s . Th us, an element of o P s is either p rf u , where u is a direct pro of of s , or ask a κ , where a : A is a query and κ : P a → o P s the con tin uation of the pro of of o P s . Bew are, one should not think of o P s as “ s follo ws from finitely many instances of P ”, b ecause the instances 4 Sheaves as oracle computations app earing in a pro of of o P s cannot in general b e collected without the aid of an oracle, for access to the next query is guarded by an answer to the previous one. Up to equiv alence, o P s ma y b e constructed as the least fixed-p oint of the monotone map f P s : Prop → Prop defined by f P s t := s ∨ ∃ a : A. ( P a ⇒ t ) . (3.1) W e now see easily that o P is a mo dality: it is monotone because f P s is monotone in the parameter s , it is obviously inflationary , and it is idemp otent b ecause o P s is a fixed p oint of f P o P s . T arski [ 28 ] constructed the least fixed-p oint of a monotone map on a complete lattice as the infimum of its prefixed p oints. In our case, r : Prop is a prefixed p oint of f P s when f P s r ⇒ r , or equiv alently ( s ⇒ r ) ⇒ ( ∀ a : A. ( P a ⇒ r ) ⇒ r ) ⇒ r . (3.2) W e may use (3.2) to chec k that o P s ≤ r holds for a given r b y verifying the pr efixe d- p oint c onditions s ⇒ r and ∀ a : A. (( P a ⇒ r ) ⇒ r ) . F unctional programmers will recognize the technique as folding and type theorists as induction . The infimum of all r ’s satisfying (3.2) is equiv alen t to o P s : o P s ⇔ ∀ r : Prop . ( s ⇒ r ) ⇒ ( ∀ a : A. ( P a ⇒ r ) ⇒ r ) ⇒ r. (3.3) The ab ov e formula is known [ 14 , 30 ] to give the least mo dality j that for c es P , by which w e mean that ∀ a : A. j ( P a ) holds. W e sa y that a predicate P : A → Prop is j -dense when it is forced by j , and similarly that a truth v alue p : Prop is j -dense when j p holds. ▶ Prop osition 3.6. A mo dality j for c es a pr e dic ate P : A → Prop if, and only if, o P ≤ j . Pro of. If o P ≤ j then j forces P b ecause o P do es, which is easily chec k ed. Conv ersely , assume j forces P and let s : Prop . T o pro v e o P s ≤ j s , we chec k the prefixed-p oint conditions: s ⇒ j s holds b ecause j is inflationary , and if a : A satisfies P a ⇒ j s then from j ( P a ) we deduce j ( j s ) , whence j s by idemp otency of j . ◀ The following corollary tells us how to compare oracle mo dalities. In Section 5 it will b e used to sho w that in realizabilit y the order on oracle mo dalities coincides with (a generalization of ) T uring reducibility . ▶ Co rollary 3.7. F or pr e dic ates P : A → Prop and Q : B → Prop , o P ≤ o Q if, and only if, ∀ a : A. o Q ( P a ) . In general, the modality o P is what it is, but in some cases it can b e computed. ▶ Example 3.8. The excluded middle oracle lem from Example 3.1 induces the double negation mo dality , o lem s ⇔ ¬¬ s . Indeed, for any s : Prop one shows o lem s ⇒ ¬¬ s b y giving in tuitionistic pro ofs of the prefixed-p oint conditions, while the con v erse ¬¬ s ⇒ o lem s follo ws from ¬¬ s ⇒ ( s ∨ ¬ s ⇒ s ) ⇒ s , which also has an intuitionistic pro of. ▶ Example 3.9. If a predicate P : A → Prop has a counter-example a : A , as in Example 3.5, then o P is the trivial mo dalit y o P s ⇔ ⊤ b ecause P a → s holds v acuously . ▶ Example 3.10. If a predicate P : A → Prop is realized by some f : ∀ a : A. P a , as in Example 3.4, then o P is the other trivial modality , namely , o P s ⇔ s . Indeed, s ⇒ o P s holds b ecause o P is inflationary , while o P s ⇒ s follows from the prefixed-p oint conditions. D. Ahman and A. Bauer 5 A predicate P : A → Prop has no counterexamples precisely when it is ¬¬ -dense , i.e., when ∀ a : A. ¬¬ P a . Example 3.9 teaches us that only ¬¬ -dense predicates b eget interesting mo dalities, but it would b e a mistake to interpret Example 3.10 as saying that ¬∀ a : A. P a is a prerequisite for having an interesting mo dality . ▶ Example 3.11. F or a more elab orate example, we draw inspiration from lo cale theory , and refer to [ 15 , §2.11] as a standard reference. Consider a meet-semilattice ( A, ⊑ , 1 , ⊓ ) , whose elemen ts are construed as the basic op ens of a space. Let ↓ a := Σ ( b : A ) . b ⊑ a b e the lo w er set of a : A , and _ ◁ _ : Π ( a : A ) . ( ↓ a → Prop ) → Prop a cov erage on A , i.e, if a ◁ U and a ⊓ b = b then b ◁ ( λ c. ∃ d : ↓ a. U d ∧ c = d ⊓ b ) . The intuitiv e meaning of a ◁ U is “the basic op en a is cov ered by the collection of basic op ens U ” . A generic p oint of the lo cale generated b y ( A, ◁ ) may be mo deled as follows. Define the predicate pt : A → Prop inductiv ely by stipulating pt 1 an pt ( a ⊓ b ) for all a, b : A suc h that pt a and pt b . W e write pt ∈ a instead of pt a to suggest the reading “the generic p oint is an elemen t of the basic op en a ” . The co v erage induces an oracle ( Σ ( a : A ) . Σ ( U : ↓ a → Prop ) . a ◁ U ) → Prop , defined by ( a, U, _ ) 7→ ( a ∈ pt ⇒ ∃ b : ↓ a. U b ∧ b ∈ pt ) . In words, if pt ∈ a and a is cov ered by U , then we ask the oracle to demonstrate that pt ∈ b for some b : ↓ a suc h that U b . The resulting mo dality ma y b e non-trivial even if the lo cale generated b y ( A, C ) has no p oints. 3.1 A caveat ab out op en mo dalities In informal mathematics, reliance on a reasoning principle ∀ a : A. P a in a pro of of a state- men t ∀ b : B . Q b is usually indicated b y a phrase suc h as “we assume ∀ a : A. P a ” . T ak en literally , this would mean that the prov en statement has the form ( ∀ a : A. P a ) ⇒ ( ∀ b : B . Q b ) , (3.4) whic h can b e expressed as the mo dal statement  ( ∀ a : A. P a ) ( ∀ b : B . Q b ) using the op en mo dality  p : Prop → Prop , defined for p : Prop as  p s := ( p ⇒ s ) . The accompan ying pro of typically establishes (3.4) not b y using the assumption ∀ a : A. P a arbitrarily , but by pro viding a functional instanc e r e duction [ 2 , 6 ]—a map h : B → A suc h that ∀ b : B . ( P ( h b ) ⇒ Q b ) , which can b e used to prov e the stronger statement ∀ b : B . o P ( Q b ) . Suc h apparent uses of the op en mo dalit y in informal mathematics thus typically arise not from a principled logical distinction but from imprecision in exposition. The oracle mo dality is therefore the more faithful interpretation of actual mathematical practice, esp ecially since the accompan ying pro ofs already conform to it. A second reason for preferring the oracle mo dality is that in realizabilit y mo dels o P s has meaningful computational conten t even when ¬∀ a : A. P a , whereas (3.4) b ecomes v acuous when the anteceden t is false. W e shall elab orate on this p oint in Section 5. 3.2 Instance reducibility Oracle mo dalities are closely related to instance reducibilit y , a notion defined in [ 6 ] as the constructiv e analogue and generalization of W eihrauc h reducibility [ 8 ]. Recall that P : A → Prop is instanc e r e ducible to Q : B → Prop , written P ≤ I Q , when ∀ a : A. ∃ b : B . ( Q b ⇒ P a ) . Kihara [ 16 ] notes that instance reducibility is like a single-query oracle computation. In our setting, his observ ation is expressed with the aid of the map i P : Prop → Prop , defined by i P s := ∃ a : A. ( P a ⇒ s ) , 6 Sheaves as oracle computations whic h expresses the fact that s follo ws from a single query to an oracle sp ecified by P . An instance reduction P ≤ I Q ma y b e stated as ∀ a : A. i Q ( P a ) , whic h we read “ i Q forces P ” . The map i P itself is not a mo dality , but it generates the corresp onding oracle mo dality . ▶ Prop osition 3.12. F or any P : A → Prop , o P is the le ast mo dality ab ove i P . Pro of. It is obvious that i P ≤ o P . Supp ose j is a mo dality and i P ≤ j . F or an y s : Prop , we c hec k o P s ≤ j s b y verifying the prefixed-p oint conditions: s ⇒ j s b ecause j is inflationary , and if a : A satisfies P a ⇒ j s then i P ( j s ) holds, hence j ( j s ) and j s do as well. ◀ A category theorist would explain Prop osition 3.12 by noting that i P is the Prop -v alued p olynomial functor for the prop ositional con tainer P , and that o P is the free monad generated on it [ 5 ]. In fact, the free monad is explicitly given as the least fixed-p oin t of f P s from (3.1) . 3.3 Every mo dalit y is an oracle mo dalit y W e next study the relationship b etw een predicates and mo dalities from a category-theoretic p ersp ective. The tw o categories of interest are the prop ositional containers PCont and the frame of mo dalities Mo d . First, the mapping from the former to the latter is functorial. ▶ Prop osition 3.13. The mapping o is a functor fr om PCont to Mo d . Pro of. Giv en a morphism f ◁ g : A ◁ P → B ◁ Q of prop ositional con tainers, w e apply Corol- lary 3.7 to reduce o P ≤ o Q to ∀ a : A. o Q ( P a ) , which is prov ed b y λ a. ask ( f a ) ( λ u. prf ( g a u )) . ◀ When lo oking for a mo dality that is not an oracle mo dality , it o ccurred to us that there isn’t one, b ecause there is a functor in the opp osite direction. Given a mo dality j , let DProp j := Σ ( s : Prop ) . j s b e the type of j -dense pr op ositions . ▶ Prop osition 3.14. Given a mo dality j , define p j to b e the pr op ositional c ontainer DProp j ◁ I j , wher e I j : DProp j → Prop is the first pr oje ction I j ( s, _ ) := s . The mapping p is a functor fr om Mo d to PCont . Pro of. Giv en mo dalities j and k , suc h that j ≤ k , let h : DProp j → DProp k act as identit y on the first comp onent and use j ≤ k on the second comp onent. It is immediate that ∀ ( s, u ) : DProp j . I k ( f ( s, u )) ⇒ I j ( s, u ) , as it is just ∀ ( s, u ) : DProp j . s ⇒ s . F unctoriality holds b ecause h acts as iden tit y on the first comp onen t and ≤ is transitive. ◀ The functors o and p are adjoint, provided we squash the morphisms in PCont . Let PCont ≤ b e the preorder reflection of PCont , i.e., ( A ◁ P ) ≤ ( B ◁ Q ) when there exists a morphism A ◁ P → B ◁ Q . ▶ Theo rem 3.15. When o and p ar e c onstrue d as functors b etwe en PCont ≤ and Mo d , o is left adjoint to p . Mor e over, p is a se ction of o . Pro of. Giv en a prop ositional container A ◁ P and a mo dality j , we need to chec k that there is a morphism A ◁ P → p j if, and only if, o P ≤ j . If o P ≤ j , then we define f : A → DProp j b y f a := ( P a, u ) , where u : j ( P a ) is pro vided b y Prop osition 3.6 b ecause j forces P . It is immediate that ∀ a : A. I j ( t a ) ⇒ P a , which is just ∀ a : A. P a ⇒ P a . If there exists a morphism f ◁ g : A ◁ P → p j of prop ositional containers, then by Prop osition 3.6 it suffices to prov e ∀ a : A. j ( P a ) . So consider any a : A , and let ( s, u ) := f a so that s : Prop and u : j s . No w g a establishes s ⇒ P a , hence j ( P a ) by monotonicity of j . D. Ahman and A. Bauer 7 It remains to show that j = o p j . The inequality o p j ≤ j holds by Prop osition 3.6 as j forces p j . T o show j ≤ o p j , consider an y s : Prop and u : j s . Then o p j s holds because ( s, u ) witnesses ∃ ( t, _ ) : DProp j . ( t ⇒ o p j s ) . ◀ ▶ Co rollary 3.16. Every mo dality is an or acle mo dality. Pro of. A mo dality j coincides with the oracle mo dality o p j . ◀ Th us, a mo dality j is the least oracle mo dality forcing j -dense prop ositions. Note that there are many predicates whose induced oracle mo dality equals j , some of which might b e more con v enien t to w ork with. F or instance, in Example 3.8 we saw that double negation is the Excluded Middle oracle mo dality; it seems easier to w ork with an oracle that decides prop ositions than one that remo v es double negations from a ¬¬ -dense prop ositions. The adjunction gives us a recip e for computing suprema of nuclei, whose direct com- putation is complicated [ 11 ], in terms of copro ducts of (prop ositional) containers, whic h is straigh tforw ard [1]. ▶ Prop osition 3.17. L et P : Π ( i : I ) . ( A i → Prop ) b e an I -indexe d family of pr e dic ates. The supr emum of o P i ’s is the or acle mo dality for the pr e dic ate Σ P : ( Σ ( i : I ) . A i ) → Prop define d by (Σ P )( i, a ) := P i a . Pro of. Immediate, b ecause o is a left adjoint and the copro duct ( Σ ( i : I ) . A i ) ◁ (Σ P ) of con tainers reflects to the supremum in PCont ≤ . ◀ 4 Sheaves for oracle mo dalities W e no w explore shea ves for oracle mo dalities. Our first goal is a t yp e-theoretic characterization of shea v es for a general mo dality that can b e usefully sp ecialized to an oracle mo dalit y . In a top os, an ob ject X is a j -sheaf when for every j -dense mono m : B → A the map − ◦ m : ( A → X ) → ( B → X ) is an isomorphism [ 18 , §5.2]. As every such mono is isomorphic to the first pro jection ( Σ ( a : A ) . P a ) → A , for some j -dense predicate P : A → Prop , the sheaf condition can b e stated in terms of precomp osing with such pro jections. After currying the pro jection ( Σ ( a : A ) . P a ) → A to Π ( a : A ) . ( P a → X ) , we arrive that the map required to b e an equiv alence is ( λ f a u. f a ) : ( A → X ) → Π ( a : A ) . ( P a → X ) . Since w e work internally in type theory , we can make further simplifications. ▶ Prop osition 4.1. Given a mo dality j and a typ e X , the fol lowing ar e e quivalent: 1. F or every j -dense P : A → Prop , the map ( λ f a u. f a ) : ( A → X ) → Π ( a : A ) . P a → X is an e quivalenc e. 2. F or every j -dense s : Prop , the map ( λ x u. x ) : X → ( s → X ) is an e quivalenc e. 3. The fol lowing c onditions hold: a. ther e is a map e : Π ( s : Prop ) . j s → ( s → X ) → X , b. e s t h = h u for al l s : Prop and t : j s and h : s → X and u : s , and c. if s ⇒ x = y then x = y , for al l j -dense s : Prop and x, y : X . When these statements hold, we say that X is a j -sheaf . Pro of. The first statement instan tiated at A = 1 yields the second statement. The third statement is just an elab oration of the second statement. Indeed, giv en a j -dense s : Prop , the map ( λ x u. x ) : X → ( s → X ) is an equiv alence when its fib ers are con tractible. The map e in the third statemen t inhabits the fib ers, while the second condition 8 Sheaves as oracle computations states that every fib er has at most one element, b ecause λ ( u : s ) . x = λ ( u : s ) . y is equiv alent to s ⇒ x = y . W e assume the third statement and prov e the first one for a giv en j -dense P : A → Prop . Item 3b implies that the fib ers of λ f a u. f a are inhabited by the v alues of λ h a. e ( P a ) _ ( h a ) . T o see that each fib er has at most one elemen t, consider f , g : A → X suc h that λ a u. f a = λ a u. g a . Then for any a : A w e hav e λ u. f a = λ u. g a , hence p ⇒ f a = g b and f a = g a b y Item 3c. W e conclude f = g by function extensionality . ◀ The following theorem sp ecializes the third statement in the lemma to oracle modalities in a w a y that av oids explicit reference to the mo dality , whic h simplifies manipulation of oracle shea v es. ▶ Theo rem 4.2. A typ e X is an o P -she af for P : A → Prop if, and only if: 1. ther e is a map d : Π ( a : A ) . ( P a → X ) → X , 2. d a h = h u for al l a : A and h : P a → X and u : P a , and 3. if P a ⇒ x = y then x = y , for al l a : A and x, y : X . Pro of. If X is an o P -sheaf, w e use e from Prop osition 4.1 to define d a h := e ( P a ) ( ask a prf ) h . It is not hard to c heck that d satisfies Item 2, while Item 3 follows from Item 3c in Prop osition 4.1, as P a is o P -dense. T o pro ve the con verse, we assume X satisfies Items 1–3 and show that it also satisfies Items 3a–3c from Prop osition 4.1. Given s : Prop , and t : o P , s , one is tempted to define e s t b y induction on t , but this is forbidden as s → X is not known to b e a prop osition. Instead, w e prov e by induction on t that ∀ h : s → X. ∃ ! x : X. ∀ u : s. x = h u , and use unique choice to extract e s t : ( s → X ) → X satisfying e s t h = h u for all h : s → X and u : s , thereby also securing Item 3b. W e omit the rather tech nical details, whic h we c heck ed with Ro cq. Finally , Item 3c follo ws from Item 3 and the next statement: given q : Prop , if ∀ a : A. ( P a → q ) → q then ∀ s : Prop . o P s → ( s → q ) → q . This time we may use induction. ◀ Henceforth we refer to o P -shea v es as P -or acle she aves or just P -she aves . W e refer to the map d from Theorem 4.2 as the structur e map of the sheaf X , and to Items 2 and 3 as the first and second she af e quality , respectively . The terminology is w arranted b ecause the theorem exhibits a sheaf as an algebra equipp ed with an op eration d taking inputs a : A and h : P a → X , and extracting the element that h w ould compute when given an answer u : P a , but without consulting the oracle. Such an X m ust b e quite sp ecial when P is non-trivial. The second sheaf equality , Item 3, similarly allo ws us to extract the equality x = y from the h yp othetical equality P a ⇒ x = y , again without consulting the oracle. W e also observe that b eing a sheaf is a prop erty , not structure, as the map d is unique when it exists. W e reprov e some known facts ab out sheav es to practice working with oracle sheav es. ▶ Co rollary 4.3. The typ e of o P -stable prop ositions Prop j := Σ ( s : Prop ) . ( o P s ⇒ s ) is a P -she af and it is e quivalent to Σ ( s : Prop ) . ( ∀ a : A. ( P a ⇒ s ) ⇒ s ) . Pro of. The structure map d : ∀ a : A. ( P a → Prop j ) → Prop j is d a h := (( ∀ u : P a. h u ) , _ ) , where _ should b e filled with a pro of of o P ( ∀ u : P a. h u ) ⇒ ∀ u : P a. h u . The pro of, as well as the v erification of sheaf equalities, are exercise in induction on pro ofs of mo dal statements. F or the equiv alence to b e established, it suffices to show, for any s : Prop , that o P s ⇒ s is equiv alen t to ∀ a : A. ( P a ⇒ s ) ⇒ s . If ∀ a : A. ( P a ⇒ s ) ⇒ s and t : o P s , then s follo ws by induction on t : if t = p rf u then u : s , and if t = ask a κ then the induction h ypothesis states P a ⇒ s , therefore s by assumption. The conv erse holds b ecause P a is o P -dense. ◀ D. Ahman and A. Bauer 9 Recall that X is j -sep ar ate d when equalit y on X is j -stable, ∀ x, y : X . j ( x = y ) ⇒ x = y . ▶ Co rollary 4.4. P -she aves ar e P -sep ar ate d. Pro of. Let X b e a P -sheaf for a predicate P : A → Prop and x, y : X suc h that t : o P ( x = y ) . W e prov e x = y b y induction on t . If t = p rf u then u : x = y . If t = ask a κ , then the induction h ypothesis states P a → x = y and so x = y by the second sheaf equality . ◀ The next corollary sa ys that all maps b etw een sheav es are homomorphisms. ▶ Co rollary 4.5. L et X and Y b e P -she aves for P : A → Prop , with structur e maps d X and d Y , r esp e ctively. Then f ( d X a h ) = d Y a ( f ◦ h ) for al l f : X → Y , a : A and h : P a → X . Pro of. W e emplo y the second sheaf equality for Y . If u : P a then the first sheaf equality implies f ( d X a h ) = f ( h u ) = ( f ◦ h ) u = d Y a ( f ◦ h ) . ◀ ▶ Co rollary 4.6. F or a P : A → Prop , P -she aves ar e close d under dep endent pr o ducts. Pro of. Algebras are closed under pro ducts. Sp ecifically , if X : I → T ype is a family of shea v es with structure maps d : Π ( i : I ) . Π ( a : A ) . ( P a → X i ) → X i , then Y := Π ( i : I ) . X i is a P -sheaf whose structure map e : Π ( a : A ) . ( P a → Y ) → Y is defined index-wise by e a h i := d i a ( λ u. h u i ) . The sheaf equations are derived index-wise, to o. ◀ ▶ Example 4.7. If P : A → Prop has a counterexample a : A , so that ¬ P a , then the P -shea v es are precisely the contractible t yp es. F or if X is a P -sheaf with structure map d , then it is inhabited by d a _ , while the second sheaf equation instantiated at a yields x = y , for an y x, y : X . ▶ Example 4.8. If P : A → Prop has a section f : ∀ a : A. P a , then every type X is a P -sheaf b ecause its structure map can b e constructed as λ a h. h ( f a ) . The sheaf equations are easily c hec ked. In other words, the section f : ∀ a : A. P a implemen ts the a P -oracle, so an y oracle questions can b e answ ered b y just consulting f . ▶ Example 4.9. F or any predicate P : A → Prop and t yp e X , the t yp e ( ∀ b : A. P b ) → X is a P -sheaf. T o satisfy Theorem 4.2, define d : Π ( a : A ) . ( P a → ( ∀ b : A. P b ) → X ) → ( ∀ b : A. P b ) → X b y d a h f := h ( f a ) f . The tw o sheaf equations are easily chec k ed. In fact, the general fact that a k -sheaf is a j -sheaf if j ≤ k is at work here, with the tw o modalities b eing o P and  ( ∀ a : A. P a ) from Section 3.1. 4.1 Sheafification In a top os, sheav es form a reflective sub category [ 18 , §5.3]. This is the case in type theory , to o, provided the setup is ric h enough to allo w sheafification, which is describ ed by the follo wing universal prop erty . ▶ Definition 4.10. Given a mo dality j , the j -sheafification of a typ e X is a j -she af shfy j X with a map η X : X → shfy j X , such that for every j -she af Y and f : X → Y ther e is a unique map f † : shfy j X → Y for which f = f † ◦ η X . The sheafification of X is unique up to isomorphism if it exists, but ho w do w e construct it? One w ay is to translate “sheafification in logical form” by Barbara V eit [ 31 ] from higher-order logic to type theory . After some calculations, which rely on having an impredicative Prop , prop ositional extensionalit y , and pro of-irrelev ance, we find out that shfy j X := Σ ( p : X → Prop j ) . j ( ∃ x : X . ∀ y : X . p y ⇔ j ( x = y )) . (4.1) 10 Sheaves as oracle computations The formula says that the elements of shfy j X are the “ j -mo dally j -mo dal singletons of X ”, for erasing j from it yields ordinary singleton subsets of X . Alternatively , if we treat P -shea v es as algebras in the sense of Theorem 4.2, then Definition 4.10 says that shfy j X is the initial algebra generated by X , which is constructed as follows. ▶ Definition 4.11. Given a pr e dic ate P : A → Prop , the P -sheafification of X is the quotient-inductive typ e shfy P X , gener ate d by the fol lowing c onstructors and e quations: ret : X → shfy P X , ask : Π ( a : A ) . ( P a → shfy P X ) → shfy P X , ask a h = h u , for al l a : A , h : P a → shfy P X , and u : P a , and if P a ⇒ v = w then v = w , for al l a : A and v , w : shfy P X . The induction principle for shfy P X states: given a she af Y with structur e d map d Y and f : X → Y , ther e is a unique map f † : shfy P X → Y such that f † ( ret x ) = f x . By quotient-inductive typ e we mean a t yp e that is generated inductiv ely by its constructors and simultaneously quotiented by its equations. Such types are instances of higher inductive t yp es in homotopy type theory [ 29 ], and were sp ecifically studied by Thorsten Altenkirch and Ambrus Kap osi [ 3 ]. T o b e precise, we require a v ariant of c onditional quotient-inductive typ es formulated by Peter Dyb jer and Hugo Mo eneclaey [ 10 ], and briefly considered by Marcelo Fiore, Andrew Pitts, and S. C. Steenkamp [ 12 ], b ecause the second sheaf equation is conditioned by a P a -indexed family of equations. W e could also construct P -sheafification b y nul lific ation of Egb ert Rijke, Mik e Shulman, and Bas Spitters [ 26 , §2.3], which is the least mo dality inv erting the maps P a → 1 , for all a : A . They to o construct the nullification as a higher-inductiv e t yp e. W e shall not dwell further on foundational assumptions that guaran tee the existence of sheafification—suffice it to say that (4.1) guaran tees its existence under our working assumptions. Observ e that in view of Corollary 4.5, we need not state that f † pro vided by the induction principle for shfy P X is a homomorphism with resp ect to the structure maps, but if we did, w e would write down the equation f † ( ask a κ ) = d Y a ( f † ◦ κ ) . W e are tempted to think of the elements of shfy P X as effectful computations on X , where ret x is the pure computation returning x : X , and ask a κ is a computation that queries a : A and pro ceeds as κ u up on receiving evidence u : P a as an answer. The first equation says that a query can b e skipp ed if the answer is already av ailable, and the second one sa ys that w e may assume answers to queries when proving equality of computations. ▶ Example 4.12. F or any P : A → Prop , a map f : X → shfy P Y can b e thought as computing its v alues with the aid of a P -oracle. Andrew Swan [ 27 ] takes such maps as the basic notion. F or example, the excluded middle oracle lem from Example 3.1 can b e used to define the halting oracle H : N × N → shfy lem N b y H ( m, n ) := ask ( ∃ k : N . T ( m, n, k )) ( λ b. if b then ret 1 else ret 0) . T o decide whether the n -th T uring mac hine stops on input m , H uses Kleene’ T predicate [ 17 ] to ask the oracle whether there is an execution trace k witnessing termination, and answers accordingly . 4.2 Equifoliate trees and projective o racle mo dalities T reating the elements of shfy P X as P -oracle computations works only so well, b ecause the quotient collapses intensional distinctions that one normally exp ects under the classic D. Ahman and A. Bauer 11 treatmen t of computations modeled by trees [ 24 ]. The sheaf equations mask information ab out whic h queries are asked, and also, computations are en tirely streamlined, as the answ er t yp e P a has at most one element. F or example, if the oracle answers an existential statement ∃ b : B . Q b b y providing a witness b and a pro of of Q b , the computation may use b only in a limited fashion b ecause neither further queries nor the returned elemen t may v ary with b . A computationally more faithful account of oracle computations would sp ecify an oracle b y a non-pr op ositional c ontainer P : A → T yp e and then mo del P -oracle computations returning v alues of type X as trees T P X , generated inductively by the constructors: leaf : X → T P X , no de : Π ( a : A ) . ( P a → T P X ) → T P X . It is natural to ask how T P X corresp onds to the sheafification shfy ∥ P ∥ X , where ∥ P ∥ : A → Prop is the pr op ositional trunc ation of P , which may b e defined as ∥ P ∥ a := ∃ u : P a. ⊤ . Without further assumptions there is no connection: a tree t ∈ T P X ma y compute differen t v alues along different paths, while attempts to lift an element of shfy ∥ P ∥ X to a tree will generally require some form of the axiom of choice. W e address the former problem first. ▶ Definition 4.13. Given P : A → Prop and a typ e X , define the membership r elation x ∈ t for x : X and t : shfy P X inductively as fol lows: x ∈ ret y if o P ( x = y ) , x ∈ ask a κ if ∀ u : P a. x ∈ κ u . F or Definition 4.13 to be well-formed, we need to c heck that ∈ resp ects the sheaf equations. F or the first equation, take an y a : A , κ : P a → shfy P X and u : P a , and observe that x ∈ ask a κ ⇔ ( ∀ v : P a. x ∈ κ v ) ⇔ x ∈ κ u b ecause all elements of P a are equal. F or the second equation, observe that x ∈ t is o P -stable b y construction. The o ccurrence of o P in the first clause of Definition 4.13 is annoying but it is needed, for in general ret x = ret y implies only o P ( x = y ) . Luckily , in many concrete cases X is P -separated, in which case the application of o P is unnecessary; one such instance o ccurs when P is ¬¬ -dense and X has ¬¬ -stable equality . The second clause also appears odd, for w ould it not b e more natural to require that x app ear in some subtree κ u instead of all of them? No, for if ¬ P a holds for some a : A , then by the second sheaf equation ask a κ and ret x are equal, for all x : X . ▶ Lemma 4.14. F or any t : shfy P X and x : X , if x ∈ t then ret x = t . Pro of. The pro of proceeds by induction on t . If t = ret y then o P ( x = y ) , therefore o P ( ret x = t ) and ret x = t b ecause sheav es are separated. If t = ask a κ then ∀ u : P a. x ∈ κ u , hence b y induction h yp othesis and the first sheaf equation ∀ u : P a. ret x = κ u = t , from whic h ret x = t by the second sheaf equation. ◀ ▶ Lemma 4.15. If s, t : shfy P X ar e such that ∀ x : X . ( x ∈ s ⇔ x ∈ t ) then s = t . Pro of. The pro of pro ceeds by induction on s and t . If s = ret x then x ∈ t and w e ma y apply Lemma 4.14. The case t = ret y is symmetric. Consider s = ask a κ and t = ask b µ . By the second sheaf equation it suffices to sho w s = t assuming u : P a and v : P b . With u and v in hand, ∀ x : X. x ∈ s ⇔ x ∈ κ u and ∀ x : X. x ∈ t ⇔ x ∈ µ v , whence ∀ x : X. x ∈ κ u ⇔ x ∈ µ v , and so by the induction hypothesis and the first sheaf equation s = κ u = κ v = t . ◀ The corresp onding notion of mem b ership for non-prop ositional contain ers is as follows. 12 Sheaves as oracle computations ▶ Definition 4.16. Given P : A → T ype and a typ e X , define the mem b ership r elation x ∈ t for x : X and t : T P X inductively as fol lows: x ∈ leaf y if o P ( x = y ) x ∈ no de a κ if ∀ u : P a. x ∈ κ u . W e now idenitfy those computation trees that compute just one elemen t, mo dally speaking. ▶ Definition 4.17. Given P : A → T ype and a typ e X , define equi : T P X → Prop inductively by the clauses: equi ( leaf x ) , for al l x : X , equi ( no de a κ ) , when ∀ u : P a. equi ( κ u ) and ∀ x : X . ∀ u, v : P a. x ∈ κ u ⇒ x ∈ κ v . A n equifoliate tree is one satisfying equi . L et E P X := Σ ( t : T P X ) . equi t b e the typ e of e quifoliate tr e es. The nomenclature is sensible b ecause an equifoliate tree computes a single element, mo dally sp eaking: ▶ Lemma 4.18. Given P : A → T ype , a typ e X , an e quifoliate tr e e t : T P X , and x, y : X , if x ∈ t and y ∈ t then o P ( x = y ) . Pro of. W e pro ceed by induction on t . If t is a leaf, the statement is immediate. If t = no de a κ then P a ⇒ o P ( x = y ) is the induction hypothesis, from which o P ( x = y ) follows. ◀ F or equifoliate trees to b e a reasonable notion of sheaf computations, they should form a monad, whic h they do. ▶ Lemma 4.19. Given P : A → T yp e , f : X → T P Y , t : E P X , and y : Y , we have y ∈ bind f t if, and only if, ∀ x : X. x ∈ t ⇒ y ∈ f x . Pro of. W e pro ceed b y induction on t . Consider the case t = leaf z . If y ∈ bind f t = f z and x ∈ t then o P ( x = z ) , so o P ( y ∈ f x ) , hence y ∈ f x . Con v ersely , if ∀ x : X. x ∈ t ⇒ y ∈ f x then y ∈ f z = bind f t b ecause z ∈ leaf z . Consider the case t = no de a κ . If y ∈ bind f t = no de a ( λ u. bind f ( κ u )) and x ∈ t then, for any u : P a , x ∈ κ u hence y ∈ f x b y the induction h yp othesis and the fact that y ∈ bind f ( κ u ) . Conv ersely , supp ose ∀ x : X. x ∈ t ⇒ y ∈ f x . It suffices to show that, for a given u : P a , we hav e y ∈ bind f ( κ u ) . By the induction h yp othesis this follows once we demonstrate ∀ x : X. x ∈ κ u ⇒ y ∈ f x . But if x ∈ κ u then ∀ v : P a. x ∈ κ v b ecause t is equifoliate, hence x ∈ t and y ∈ f x by assumption. ◀ ▶ Theo rem 4.20. The tr e e monad on T P r estricts to E P , for any P : A → T ype . Pro of. The unit of the tree monad is leaf , and leav es are equifoliate. T o show that bind restrict to equifoliate trees as well, consider any f : X → E P Y and t : E P X . W e show that bind f t is equifoliate by induction on t . If t = leaf x then bind f t = f x is equifoliate by assumption. Consider the case t = no de a κ , so bind f t = no de a ( λ u. bind f ( κ u )) . The subtrees of bind f t are equifoliate by the induction h yp othesis. Given y : Y and u, v : P a suc h that y ∈ bind f ( κ u ) , we need to show y ∈ bind f ( κ v ) . By Lemma 4.19, ∀ x : X. x ∈ κ u ⇒ y ∈ f x . Because t is equifoliate, this implies ∀ x : X. x ∈ κ v ⇒ y ∈ f x , and then Lemma 4.19 gets us the desired y ∈ bind f ( κ v ) . ◀ Equifoliate trees compute elements of a sheafification. D. Ahman and A. Bauer 13 ▶ Theo rem 4.21. Given P : A → T yp e , ther e is a map δ P : E P X → shfy ∥ P ∥ X such that, for al l x : X and t : E P X , x ∈ t ⇔ x ∈ δ P t . Pro of. W e define δ P b y induction on its argument and simultaneously show that it has the required prop ert y . F or any y : X , define δ P ( leaf y ) := ret y and note that x ∈ leaf y ⇔ o P ( x = y ) ⇔ x ∈ ret y , for any x : X . Consider an equifoliate tree no de a κ , where a : A and κ : P a → E P X , and supp ose δ P ( κ u ) is already defined for all u : P a , and also ∀ x : X. ( x ∈ κ u ⇔ x ∈ δ P ( κ u )) . W e claim that for all u, v : P a , we hav e δ P ( κ u ) = δ P ( κ v ) : indeed, by the assumption and Lemma 4.15 it suffices to show ∀ x : X. ( x ∈ κ u ⇔ x ∈ κ v ) , which holds b ecause no de a κ is equifoliate. The claim implies that δ P ◦ κ factors through the quotient map P a → ∥ P a ∥ as µ : ∥ P a ∥ → shfy ∥ P ∥ X . W e now define δ P ( no de a κ ) := ask a µ . ◀ In an ideal world δ P : E P X → shfy ∥ P ∥ X w ould b e surjective, but in our setting a price m ust b e paid. Recall that a t yp e X is pr oje ctive if every total relation on X has a choice function, i.e., for any type Y and R : X → Y → Prop , ( ∀ x : X. ∃ y : Y . R x y ) ⇒ ( ∃ f : X → Y . ∀ x : X . R x ( f x ) . W e say that P : A → T yp e is pr oje ctive when P a is pro jective for every a : A . ▶ Theo rem 4.22. If P : A → T ype is a pr oje ctive c ontainer then δ P is surje ctive. Pro of. W e show ∀ t : shfy P X. ∃ e : E P X. δ P e = t b y induction on t . If t = ret x then e := leaf x do es the job. If t = ask a κ then by induction hypothesis ∀ u : P a. ∃ d : E P X. δ P d = κ | u | . Because P is pro jective, there is ζ : P a → E P X suc h that δ P ( ζ u ) = κ | u | for all u : P a . Therefore, δ P ( no de a ζ ) = ask a κ by the construction of δ P . ◀ The theorem is most useful in mo dels that hav e enough pro jective families, such as the realizabilit y mo dels w e discuss next. 5 Mo dalities in realizability top oses Finally , we take a closer lo ok at oracle mo dalities in the context of realizability . As the topic is quite sp ecialized, we con ten t ourselv es with brief descriptions and assume familiarit y with the notation and terminology of [ 6 , Sec. 3], where a quick ov erview of realizability theory is a v ailable, or with the standard reference for realizability theory by Jaap v an Oosten [ 30 ]. W e w ork with a r elative r e alizability top os RT ( A , A ′ ) ov er a partial com binatory algebra A with an elementary subaglebra A ′ ⊆ A . Our goal is to give an explicit description of mo dalities in RT ( A , A ′ ) . ▶ Lemma 5.1. If q : B → A is surje ctive and P : A → Prop then o P = o P ◦ q . Pro of. By Prop osition 3.12, b ecause P and P ◦ q are instance reducible to eac h other. ◀ Lemma 5.1 allows us to restrict attention to oracles induced by predicates on partitioned assem blies, b ecause every ob ject is cov ered by one [ 30 , Prop. 3.2.7]. A p artitione d assembly X = ( X, ρ X ) is given by a set X and a map ρ X : X → A whic h assigns to each x ∈ X its unique realizer ρ X x . Note that different elements may share the same realizer. A predicate on a partitioned assem bly X is given by a map P : X → P A . 14 Sheaves as oracle computations A straightforw ard calculation shows that the oracle mo dality o P is represented by a map O P : P A → P A , whose v alue at S ∈ P A is the least O P S ∈ P A satisfying O P S = {⟨ 0 , a ⟩ | a ∈ S } ∪ S x ∈ X {⟨ 1 , ⟨ ρ X x, c ⟩⟩ | c ∈ A ∧ ∀ d ∈ P x. (( c · d ) ↓ ∧ c · d ∈ O P S ) } . (5.1) An element of O P S enco des a well-founded tree. A leaf takes the form ⟨ 0 , a ⟩ where a ∈ S . A no de is a triple ⟨ 1 , ⟨ ρ X x, b ⟩⟩ for some x ∈ X , with ρ X x enco ding information ab out x , and b computing the P x -branching subtrees. W e may rephrase (5.1) in terms of W eihrauc h reducibilit y [ 8 ]. An extende d W eihr auch pr e dic ate [ 6 , Def. 3.7] is a map f : A → P ( P A ) , and its supp ort is ∥ f ∥ := { r ∈ A | f r  = ∅} . W e say that f is W eihr auch r e ducible to g : A → P ( P A ) , written f ≤ W g , when there exist ℓ 1 , ℓ 2 ∈ A ′ suc h that for all r ∈ ∥ f ∥ : ℓ 1 · r ↓ and ℓ 1 · r ∈ ∥ g ∥ , for ev ery θ ∈ f r there is ξ ∈ g ( ℓ 1 · r ) such that ℓ 2 · r ⊩ ξ ⇒ θ . (Recall from [ 6 , Sec. 3.2] that ℓ 2 · r ⊩ ξ ⇒ θ means: if s ∈ ξ then ( ℓ 2 · r · s ) ↓ and ℓ 2 · r · s ∈ θ .) The (large) preorder of instance reducibilities in RT ( A , A ′ ) is equiv alent to the (small) preorder ≤ W on extended W eihrauc h predicates [ 6 , Prop. 3.8]. Therefore, no generality is lost when oracle modalities are expressed in terms of extended W eihrauc h predicates. The oracle mo dality O f : P A → P A induced by an extended W eihrauch predicate f that maps S ∈ P A to the least O f S satisfying O f S = {⟨ 0 , a ⟩ | a ∈ S } ∪ S b ∈ A S θ ∈ f b {⟨ 1 , b, c ⟩ | c ∈ A ∧ ∀ d ∈ θ . (( c · d ) ↓ ∧ c · d ∈ O f S ) } . (5.2) One can chec k that the ab ov e-mentioned equiv alence [ 6 , Prop. 3.8] transforms (5.1) to (5.2) . W e see again that the elements of O f S enco de well-founded trees, except that tree branching is organized differently from (5.1) , namely , by a realizer b ∈ A and θ ∈ f r . Note that the realizer ⟨ 1 , b, c ⟩ carries no information ab out θ . ▶ Theo rem 5.2. In a r elative r e alizability top os RT ( A , A ′ ) , every L awver e-Tierney top olo gy is of the form (5.1) , e quivalently (5.2) . Pro of. Combine Corollary 3.16 and Lemma 5.1. ◀ The form ula (5.2) rev eals a close connection with T aka yuki Kihara’s game-theoretic description [ 16 ] of mo dalities. An extended W eihrauc h predicate f : A → P ( P A ) describ es a game: Arthur either terminates the game with a final mov e a ∈ S , or plays a mo ve b ∈ ∥ f ∥ , after whic h Nimue pla ys θ ∈ f b , and Merlin resp onds with d ∈ θ . Kihara’s winning strategies for Arth ur and Nimue corresp ond to well-foundedness of trees enco ded by O f S . 6 Related and further wo rk Shea v es in the context of type theory hav e b een studied by a num b er of authors. Erik P almgren [ 22 ] and Ieke Mo erdijk and Eirk Palmgren [ 20 ] gav e an early predicative account of sheav es. In the context of homotopy t yp e theory , Kevin Quirin and Nicolas T abareau [ 25 ] formalized sheav es for general mo dalities, Egb ert Rijke, Mik e Shulman, and Bas Spitters [ 26 ] ga v e a general accoun t of mo dalities, and Thierry Co quand, F abian Ruc h, and Christian Sattler [9] studied constructiv e sheaf mo dels of type theory . D. Ahman and A. Bauer 15 Closer to our work are studies of sheav es that fo cus on computation and computability . Martín Escardó and Chuangjie Xu [ 32 ] used sheav es on the Cantor space in type theory to show that every System T definable functional is contin uous. Their work w as expanded to dep endent functionals by Martin Baillon, Assia Mah boubi, and Pierre-Marie Pédrot [ 4 ], where the oracle query-answ er trees featured prominen tly . W e were inspired by the work of Andrew Sw an [27] on oracle mo dalities in cubical assemblies. In the present work the computational viewp oint of sheav es as oracle computations is central. Our description of a mo dality in terms of oracle queries and answers is b oth concrete and general. It reveals a connections b etw een mo dalities and containers that will hop efully turn out to b e useful in the future. Sheafification as a quotien t-inductive type is to o extensional to giv e a faithful account of oracle computations. W e hav e tried to improv e on it b y iden tifying the notion of equifoliate trees. These are not quotiented, but rather restricted in what answers they provide, and they are parameterized b y general, non-propositional, con tainers. It remains to b e seen whether they b eget a satisfactory theory of what one might call “in tensional sheav es” . References 1 Mic hael Gordon Abbott, Thorsten Altenkirch, and Neil Ghani. Con tainers: Constructing strictly p ositive types. The or etic al Computer Scienc e , 342(1):3–27, 2005. doi:10.1016/J.TCS. 2005.06.002 . 2 Danel Ahman and Andrej Bauer. Como dule representations of second-order functionals. Journal of L o gic al and Algebr aic Metho ds in Pr o gramming , 146:101071, 2025. doi:10.1016/j. jlamp.2025.101071 . 3 Thorsten Altenkirch and Am brus Kap osi. Type theory in type theory using quotient inductive t yp es. In Pr o c e e dings of the 43r d A nnual A CM SIGPLAN-SIGA CT Symp osium on Principles of Pro gr amming L anguages , POPL ’16, pages 18–29, New Y ork, NY, USA, 2016. Asso ciation for Computing Machinery . doi:doi.org/10.1145/2914770.2837638 . 4 Martin Baillon, Assia Mah b oubi, and Pierre-Marie Pédrot. Gardening with the Pythia A Mo del of Contin uity in a Dep endent Setting. In Florin Manea and Alex Simpson, editors, 30th EA CSL Annual Confer enc e on Computer Science L o gic (CSL 2022) , volume 216 of L eibniz International Pr o c e e dings in Informatics (LIPIcs) , pages 5:1–5:18, Dagstuhl, Germany , 2022. Sc hloss Dagstuhl – Leibniz-Zen trum für Informatik. doi:10.4230/LIPIcs.CSL.2022.5 . 5 Mic hael Barr. Co equalizers and free triples. Mathematische Zeitschrift , 116(4):307–322, 1970. doi:10.1007/BF01111838 . 6 Andrej Bauer. Instance reducibilit y and W eihrauc h degrees. L o gic al Metho ds in Computer Scienc e , 18(3), 2022. doi:10.46298/LMCS- 18(3:20)2022 . 7 E. Bishop. F oundations of Constructive A nalysis . McGraw-Hill, 1967. 8 V asco Brattka and Guido Gherardi. W eihrauc h degrees, omniscience principles and weak com- putabilit y . The Journal of Symb olic L o gic , 76(1):143–176, 2011. doi:10.2178/jsl/1294170993 . 9 Thierry Co quand, F abian Ruc h, and Christian Sattler. Constructive sheaf mo dels of t yp e theory . Mathematic al Structur es in Computer Scienc e , 31(9):979–1002, 2021. doi:10.1017/ S0960129521000359 . 10 P eter Dybjer and Hugo Mo eneclaey . Finitary higher inductiv e types in the group oid model. Ele ctr onic Notes in The oretic al Computer Scienc e , 336:119–134, 2018. The Thirty-third Conference on the Mathematical F oundations of Programming Semantics (MFPS XXXI I I). doi:10.1016/j.entcs.2018.03.019 . 11 Martín H. Escardó. Joins in the frame of n uclei. Applie d Cate goric al Structur es , 11:117–124, April 2003. doi:10.1023/A:1023555514029 . 16 Sheaves as oracle computations 12 Marcelo P . Fiore, Andrew M. Pitts, and S. C. Steenkamp. Quotien ts, inductiv e t yp es, and quotient inductive types. L o gic al Metho ds in Computer Scienc e , 18(2), 2022. doi: 10.46298/lmcs- 18(2:15)2022 . 13 Nicola Gam bino and Joachim Kock. Polynomial functors and p olynomial monads. Mathematic al Pr o c ee dings of the Cambridge Philosophic al So ciety , 154(1):153–192, 2013. doi:10.1017/ S0305004112000394 . 14 J.M.E. Hyland. The effectiv e topos. In A.S. T ro elstra and D. v an Dalen, editors, The L. E. J. Br ouwer Centenary Symp osium , volume 110 of Studies in L o gic and the F oundations of Mathematics , pages 165–216. Elsevier, 1982. doi:10.1016/S0049- 237X(09)70129- 6 . 15 P eter T. Johnstone. Stone sp ac es . Number 3 in Cambridge Studies in Adv anced Mathematics. Cam bridge Univ ersit y Press, 1982. 16 T akayuki Kihara. Lawv ere-tierney top ologies for computability theorists. T r ansactions of the A meric an Mathematic al So ciety Series B , 10:48–85, January 2023. doi:10.1090/btran/134 . 17 S. C. Kleene. Recursiv e predicates and quan tifiers. T r ansactions of the A meric an Mathematic al So ciety , 53:41–73, 1943. doi:10.2307/1990131 . 18 Saunders Mac Lane and Ieke Mo erdijk. She aves in Ge ometry and L o gic – A first intro duction to topos the ory . Springer V erlag, 1992. 19 William F. Lawv ere. Quan tifiers and sheav es. Actes Du Congr ès International Des Math- ématiciens , 1:329–334, 1970. 20 Iek e Moerdijk and Erik P almgren. T yp e theories, top oses and constructiv e set theory: predicativ e aspects of ast. Annals of Pur e and Applie d L o gic , 114(1):155–201, 2002. doi: 10.1016/S0168- 0072(01)00079- 3 . 21 Nelson Niu and David I. Spiv ak. Polynomial F unctors: A Mathematical The ory of Inter action . T op os Institute, 2023. 22 Erik Palmgren. Constructive sheaf seman tics. Mathematic al L o gic Quarterly , 43:321–327, 1997. doi:10.1002/malq.19970430304 . 23 Christine Paulin-Mohring. Introduction to the Calculus of Inductive Constructions. In Bruno W oltzenlogel Paleo and Da vid Delahay e, editors, Al l about Pr o ofs, Pr o ofs for Al l , v olume 55 of Studies in Lo gic (Mathematic al lo gic and foundations) . College Publications, Jan uary 2015. 24 Gordon D. Plotkin and John P ow er. Notions of computation determine monads. In Mogens Nielsen and Uffe Engb erg, editors, F oundations of Softwar e Scienc e and Computation Struc- tur es, 5th International Confer enc e, FOSSA CS 2002. Grenoble, F r anc e, April 8–12, 2002, Pr o c ee dings , volume 2303 of L e cture Notes in Computer Science , pages 342–356. Springer, 2002. doi:10.1007/3- 540- 45931- 6 _ 24 . 25 Kevin Quirin and Nicolas T abareau. Lawv ere-Tierney sheafification in Homotop y Type Theory. Journal of F ormalize d R e asoning , 9(2):131–161, January 2016. doi:10.6092/issn.1972- 5787/ 6232 . 26 Egb ert Rijke, Mic hael Shulman, and Bas Spitters. Mo dalities in homotopy t yp e theory . L o gic al Metho ds in Computer Science , 16, January 2020. doi:10.23638/LMCS- 16(1:2)2020 . 27 Andrew W. Sw an. Oracle mo dalities. Preprin t arXiv:2406.05818, June 2024. doi:10.48550/ arXiv.2406.05818 . 28 A. T arski. A lattice-theoretical fixpoint theorem and its applications. Pacific Journal of Mathematics , 5(2):285–309, 1955. doi:10.2140/pjm.1955.5.285 . 29 The Univ alent F oundations Program. Homotopy T yp e The ory: Univalent F oundations of Mathematics . https://homotopytypetheory.org/book , Institute for Adv anced Study , 2013. 30 Jaap v an Oosten. Re alizability: A n Intro duction T o Its Cate goric al Side , v olume 152 of Studies in logic and the foundations of mathematics . Elsevier, 2008. 31 Barbara V eit. A pro of of the asso ciated sheaf theorem by means of categorical logic. The Journal of Symb olic L o gic , 46(1):44–55, March 1981. doi:10.2307/2273255 . D. Ahman and A. Bauer 17 32 Ch uang jie Xu and Martín Escardó. A constructive mo del of uniform contin uity . In T yp e d L amb da Calculi and Applic ations (TLCA) , volume 7941 of L e ctur e Notes in Computer Scienc e , pages 236–249. Springer Berlin Heidelb erg, 2013. doi:10.1007/978- 3- 642- 38946- 7 _ 18 .

Original Paper

Loading high-quality paper...

Comments & Academic Discussion

Loading comments...

Leave a Comment