Abstract 1 Introduction 2 Background on Boolean-Valued Set Theory 3 Boolean-Valued Setoids 4 Models of Untyped Lambda-calculus in Boolean-valued sets 5 Random Variables 6 Conclusions References Appendix A Appendix

Interpreting Lambda Calculus in Domain-Valued Random Variables

Robert Furber ORCID Heriot-Watt University, Edinburgh, UK Radu Mardare ORCID Heriot-Watt University, Edinburgh, UK Prakash Panangaden ORCID McGill University, Montreal, Canada Dana Scott Carnegie Mellon University, Pittsburgh, PA, USA
Abstract

We develop Boolean-valued domain theory and show how the lambda-calculus can be interpreted using domain-valued random variables. We focus on the reflexive domain construction rather than the language and its semantics. We develop the Boolean-valued set theory needed from scratch and then develop Boolean-valued domain theory on top of that. The notions of equality and partial order have to be given Boolean-valued interpretations; when we say that an equation is valid in the model we mean that its interpretation is the top element of the Boolean algebra.

Keywords and phrases:
lambda calculus, domain theory, random variables
Copyright and License:
[Uncaptioned image] © Robert Furber, Radu Mardare, Prakash Panangaden, and Dana Scott; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation
; Theory of computation Probabilistic computation ; Theory of computation Lambda calculus ; Theory of computation Denotational semantics
Related Version:
Full Version: https://arxiv.org/abs/2112.06339
Editors:
Stefano Guerrini and Barbara König

1 Introduction

There has been burgeoning interest in probabilistic programming languages in the last decade. The main motivation is building compositional models of probabilistic processes and performing inference on them [25, 16, 33]. For machine learning applications the notion of conditioning is fundamental and the striking results of [1, 2] show that this is a subtle issue.

The combination of probability and higher type programming has been both technically challenging and important for the development of semantics for such languages. There are a variety of approaches based on probabilistic coherence spaces [10] or cones [9], quasi-Borel spaces [31, 17, 32] and Boolean-valued models [3] which was based on Dana Scott’s vision [28]. Stochastic lambda-calculi have appeared [6, 7, 8] with important contributions to the understanding of probability theory at higher type. The work on quasi-Borel spaces gives a cartesian closed category that can serve as the foundation for a typed higher-order probabilistic programming language [17].

In [3] a Boolean-valued domain theory was developed. The idea is to use one of the standard set-theoretic models of the λ-calculus but interpreted in a suitable Boolean-valued universe of sets. However, the basic domain theoretic definitions of directed set, supremum, reflexive dcpo and continuity were interpreted as usual. The theory presented there is rather complicated and had artificial restrictions on the way randomness was handled. In the present paper a completely Boolean-valued point of view is adopted and even basic concepts, like equality and order, are all interpreted in a Boolean-valued logic. This leads to a much simpler theory but still in line with the vision of [28]. The version of Boolean-valued domain theory used in the current paper supersedes [3] by working “internally”, by transferring theorems from ordinary logic to Boolean-valued logic as much as possible, rather than the “bare handed” approach of [3].

We show that untyped λ-calculus can be interpreted in domain-valued random variables. In order to employ the theory of Boolean-valued sets, for most of the article we actually use the Boolean-valued power set rather than random variables, and then show that there is an isomorphism between the two at the end. We focus on the reflexive domain construction rather than the language and its semantics.

The main contribution of this paper is the completely Boolean-valued reconstruction of domain theory. The notion of equality has to be interpreted in the Boolean algebra and when we say that an equation is valid in the model we mean that its interpretation is the top element of the domain.

What makes the theory of Boolean-valued sets necessary is that domain-valued random variables do not form a continuous dcpo. However, when “continuous dcpo” is given its interpretation in Boolean-valued sets, they are. The version of Boolean-valued sets we have used is the original version in terms of a cumulative hierarchy. If the reader prefers, they may rephrase the arguments results in terms of topos theory in a Boolean topos, and we outline the connection of the two in Section 3, though the only part of this theory that we use is the ability to define functions. As an example of how to apply Boolean-valued domain theory, we show that there exist two sets of integers, neither of which can be mapped to the other by a λ-definable function. The reason for choosing this example is that it shows that λ-calculus and its model based on domain-valued random variables are powerful enough to prove a fact that does not mention probability in its statement, and such that the proof is pure λ-calculus and probability and doesn’t need to pass via the equivalence between λ-definability and general recursion and applying the Kleene-Post theorem [20] that there are incomparable many-one degrees. The proof, however, is inspired by Spector’s probabilistic proof [30].

For reasons of space, the complete proofs of some results are omitted, even from the appendix. However, they can be found in the “related version” on the arxiv, linked above.

2 Background on Boolean-Valued Set Theory

In this section we describe how statements and proofs in ordinary set theory can be re-interpreted in a Boolean-valued sense. This interpretation is originally due to Scott and Solovay [26, 19, 5].

Throughout this section we let A be an arbitrary complete Boolean algebra. It will play the role that the two-element Boolean algebra 2 plays in ordinary logic. We can build up the class of A-valued sets, VA, by considering an A-valued set X to be a partial function that assigns to each element x of its domain the amount, valued in A, that x is an element of X. We build up VA by the following generalization of von Neumann’s construction:

V0A=,Vα+1A={f:VαAA},VαA=β<αVβAfor α a limit ordinal.

Then either informally, or using proper classes, VA=α𝐎𝐫𝐝VαA.

We use the term A-valued set for the elements of VA, but we also will use the shorter term A-set, and this helps to avoid certain confusions arising from the term “valued”.

We can then interpret , and = by the following mutually recursive formulas:

xX=tdomXx=tX(t) XY=tdomXX(t)tY
x=y=xyyx.

In the above, and all that follows, we use an operator precedence convention for and that agrees with operator precedence for and , so there is an implicit bracket around everything to the right of such a join or meet.

Recall that the first-order language of set theory, which we write as 𝔏𝐒𝐞𝐭, is the usual first-order language for a signature with equality and one two-place relation symbol, namely . We write 𝔏𝐒𝐞𝐭(VA) for this language extended with constants from VA.

In any Boolean algebra, we can interpret the connectives of propositional logic. Using the completeness of A, we can interpret the universal quantifier as a meet and the existential quantifier as a join. All together, this gives us an interpretation of 𝔏𝐒𝐞𝐭(VA) in VA.

Theorem 1 (VA as a model).
  1. (i)

    If ϕ𝔏𝐒𝐞𝐭(VA) is a theorem of ZFC set theory, then ϕ=1 in VA.

  2. (ii)

    The inference rules of first-order logic can be applied to theorems of ZFC set theory and statements about elements of VA in 𝔏𝐒𝐞𝐭(VA).

  3. (iii)

    If x.Φ(x,X1,,Xn)=a, where X1,,XnVA (and we allow n=0), then there exists X0VA such that Φ(X0,X1,,Xn)=a.

The constructions of singletons {x}A, unordered pairs {x,y}A and ordered pairs (x,y)A are done as usual in set theory, but interpreted in VA. Details can be found in the arxiv version. For X,YVA we define X×AY as follows.

X×AY:{(x,y)Axdom(X),ydom(Y)}A

(X×AY)(x,y)A=xXyY.
For each A-set X, the A-valued power set 𝒫A(X) is defined by

dom(𝒫A(X))={uVAdom(u)=dom(X) and tdom(u).u(t)X(t)}

𝒫A(X)(u)=1
For all S,XVA we have S𝒫A(X)=SX, which is how the power set axiom is proved for VA.
If Φ is a set-theoretic formula we can define the A-set

{xXΦ(x)}A:dom(X)A by
{xXΦ(x)}A(t)=X(t)Φ(t),

which proves the axiom of separation for VA.

If we now consider von Neumann’s universe V of classic set theory constructed inductively on ordinals α𝐎𝐫𝐝, then for each set SVα, there is a corresponding element SˇVαA defined recursively. The domain of Sˇ is {xˇxS}, and it is defined by:

ˇ=,and Sˇ(xˇ)=1for all xS.

To describe how a statement in set theory about an ordinary set in XV translates to a statement about XˇVA, we need the notion of a Δ0 statement. Bounded quantifiers are those of the form xX.Φ(x) and xX.Ψ(x), i.e. in the language of set theory x.xXΦ(x) and x.xXΨ(x). A Δ0 formula Φ𝔏𝐒𝐞𝐭(VA) is one containing only bounded quantifiers. We have Δ0 invariance111Note that Bell uses the alternative terminology “restricted” for Δ0. [19, Lemma 14.21] or [5, Theorem 1.23 (v)].

Theorem 2 (Δ0 invariance).

Let Φ(x1,,xn) be a Δ0-formula, whose free variables are x1,,xn. Let X1,,XnV. Then, Φ(X1,,Xn)Φ(Xˇ1,,Xˇn)=1.

We point out some useful consequences of Theorem 2. The statements “S is a singleton whose only element is x”, “S is an unordered pair of x and y” and “S is an ordered pair, first element x, second element y” are all Δ0 statements, and so the following all hold

{x}ˇ ={xˇ}A {x,y}ˇ ={xˇ,yˇ}A (x,y)ˇ =(xˇ,yˇ)A.

Another important consequence of Theorem 2 is that ωˇ is the smallest inductive222In the sense used to formulate the axiom of infinity in ZF. A-set in VA, so that ωˇ is the ω of VA. Given any set X, we say a subset SX is finite if there exists nω and f:nX such that S=im(f). We write 𝒫fin(X) for the set of all finite subsets of X. If we interpret this with A-sets, for each XVA we can define 𝒫finA(X) to be the set of finite A-subsets of X, using the axiom of separation. The following proposition is a consequence of the distributive law – see [21, 3.1.11].

Proposition 3.

For all sets X, 𝒫finA(Xˇ)=𝒫fin(X)ˇ=1.

We can define the category 𝐒𝐞𝐭A from VA as follows. The class of objects is VA, and for each X,YVA, the set of functions {X𝐴Y}VA can be defined using products, power set, and the axiom of separation. We define:

𝐒𝐞𝐭A(X,Y) ={fdom({X𝐴Y})f{X𝐴Y}=1}/,

where is the equivalence relation defined by fg iff f=g=1. Identity elements are defined as identity relations, and composition by composition of relations, which is well-defined with respect to .

3 Boolean-Valued Setoids

We now discuss the kind of “Boolean-valued sets” that are essentially A-valued models of the theory of =. These can be considered an alternative description of either sheaves or separated presheaves on A, and are usually discussed in the more general case where A is a Heyting algebra, such as in [12, 15, 24]. Although we will use only one definition of A-valued sets, the distinction between A-valued relations that satisfy the definition of a function internally and functions that do so gives us two distinct categories.

In order to distinguish the A-valued sets we will be discussing from elements of VA, we call them A-valued setoids333Setoid is a long-established term for a set equipped with an equivalence relation., or simply A-setoids. An A-setoid is a pair (X,=X) where X is a set, =X:X×XA. The two axioms of =X are symmetry and transitivity, i.e.

x,yX.x=yX =y=xX
x,y,zX.x=yXy=zX x=zX.

so A-valued setoids are “A-valued partial equivalence relations”.

Since reflexivity is not assumed, the statement x=xX does not represent a tautology, but its intended interpretation is, in some sense, the degree to which xX, or the place where xX. So we define the notation εX(x)=x=xX.

We say (X,=X) is total if x=xX=1 for all xX, i.e. if reflexivity holds; it is strict if x=yX=1 implies x=y.

Definition 4.

Let (X,=X) be an A-setoid. We say it is complete444This definition is slightly different from that used in [12, 4.10,4.11] and elsewhere, which would not suit us because under that definition 𝒫A(X) is not complete, when considered as an A-setoid in the sense we will define in Definition 14. if either, hence both, of the following equivalent properties holds:

  1. (i)

    For any family of elements (ai)iI in A and corresponding family (xi)iI in X such that for all i,jI, aiajxi=xjX, there exists xX such that for all iI, aixi=xX.

  2. (ii)

    For any pairwise disjoint family of elements (ai)iI in A and corresponding family (xi)iI in X such that for all iI, aixi=xiX, there exists xX such that for all iI, aixi=xX.

Definition 5.

If (X,=X) is an A-setoid and (Y,=Y) is a set and a function =Y:Y×YA, and f:XY is a bijection such that for all x1,x2X:

f(x1)=f(x2)Y=x1=x2X,

then we say f is a strict isomorphism, and it follows that (Y,=Y) is an A-setoid, and is total, strict or complete iff (X,=X) is.

Definition 6.

The product (X,=X)×(Y,=Y) is defined to have

(x,y)=(x,y)X×Y=x=xXy=yY.
Definition 7.

A predicate on (X,=X) is a function S:XA such that:

  1. (i)

    For all x1,x2X, x1=x2XS(x1)S(x2).

  2. (ii)

    For all xX, S(x)εX(x).

A binary relation XY is simply a predicate on X×Y.

This allows us to define a category of setoids with relations that satisfy the internal definition of a function (“relational functions”) as morphisms.

Definition 8.

The category 𝐒𝐞𝐭𝐨𝐢𝐝𝐑A has A-setoids as objects and a morphism is a relation f:XY such that (additionally to (i) and (ii) from Definition 7):

  1. (iii)

    For all xX, y1,y2Y, f(x,y1)f(x,y2)y1=y2Y.

  2. (iv)

    For all xX, εX(x)yYf(x,y).

The identity function idX:XX is defined by: idX(x1,x2)=x1=x2X.
Composition of functions f:XY and g:YZ is defined by

(gf)(x,z)=yYf(x,y)g(y,z).

We define the category of A-setoids and “functional functions”, 𝐒𝐞𝐭𝐨𝐢𝐝𝐅A, as follows.

Definition 9.

The category 𝐒𝐞𝐭𝐨𝐢𝐝𝐅A has A-setoids as objects. The morphisms are defined starting with an A-setoid:

XY ={f:XYx1,x2X.x1=x2Xf(x1)=f(x2)Y}
f1=f2XY =xXεX(x)f1(x)=f2(x)Y.

Then the hom set 𝐒𝐞𝐭𝐨𝐢𝐝𝐅A(X,Y) is the quotient set of this,555Monro calls these admissible functions in [24, Definition 5.2]. i.e. XY modulo the equivalence relation:

f1f2 iff xX.εX(x)f1(x)=f2(x)Y.

Identity maps and composition are defined as for functions.

The category 𝐒𝐞𝐭𝐨𝐢𝐝𝐅A is called 𝐌𝐨𝐝0(A) in [24, Definition 5.2], where it is proved to be a quasi-topos. The full subcategory on non-empty666We mean not having as an underlying set. It is still allowed, and necessary, to have sets that do not assign any value other than 0 to any element, which are “empty” in terms of Boolean-valued logic. complete A-setoids is a topos [24, Proposition 5.6 (ii)] equivalent to the category of sheaves on the canonical topology on A.

Mapping a functional function to its graph defines a faithful functor from 𝐒𝐞𝐭𝐨𝐢𝐝𝐅A𝐒𝐞𝐭𝐨𝐢𝐝𝐑A.

Definition 10.

The following defines a faithful functor 𝛄:𝐒𝐞𝐭𝐨𝐢𝐝𝐅A𝐒𝐞𝐭𝐨𝐢𝐝𝐑A. On objects, 𝛄(X,=X)=(X,=X). For f𝐒𝐞𝐭𝐨𝐢𝐝𝐅A(X,Y), we define

𝜸(f)(x,y)=εX(x)f(x)=yY.

We can formulate a notion of poset that does not require us to define =X but can instead be defined in terms of it. It turns out to be useful in the general theory, as well as for dealing with posets that are A-setoids or A-sets.

Definition 11.

An A-poset is a pair (X,X), where X is a set and X:X×XA is such that for all x1,x2,x3X:

  1. (i)

    x1x2Xx2x3Xx1x3X.

  2. (ii)

    x1x2Xx1x1Xx2x2X.

We then define =X by

x1=x2X=x1x2Xx2x1X. (1)

Then (X,=X) is an A-setoid, and X is a reflexive, antisymmetric, transitive relation when these statements are interpreted in the A-valued sense. If (X,=X) is an A-setoid and X is a relation that is reflexive, antisymmetric and transitive, in the A-valued sense, then (X,X) is an A-poset in the above sense, and =X satisfies (1).

Since =X is defined in terms of X, the following fact is convenient for proving that a function on underlying sets f:XY not only defines an element of 𝐒𝐞𝐭𝐨𝐢𝐝𝐅A(X,Y) but also a monotone function in the A-valued sense.

Lemma 12.

Let (X,X),(Y,Y) be A-posets, and suppose that f:XY is A-monotone in the sense777This is monotonicity using the interpretation of logic in Section 2. that for all x1,x2X, x1x2Xf(x1)f(x2)Y.
Then fXY. Every f𝐒𝐞𝐭𝐨𝐢𝐝𝐅A(X,Y) that is monotone in the A-valued interpretation of the term is of this form.

The following definition and theorem are based on [23, Proposition 3.3].

Definition 13.

Let (X,=X),(Y,=X) be A-setoids such that Y is complete, and let f𝐒𝐞𝐭𝐨𝐢𝐝𝐑A(X,Y). For each xX, there exists 𝓕(f)(x)Y such that

f(x,y)𝓕(f)(x)=yY. (2)

Any choice of 𝓕(f)(x) for all xX defines an element 𝓕(f)𝐒𝐞𝐭𝐨𝐢𝐝𝐅A(X,Y) such that 𝛄(𝓕(f))=f, and in fact this establishes a 𝐒𝐞𝐭𝐨𝐢𝐝𝐅A isomorphism 𝐒𝐞𝐭𝐨𝐢𝐝𝐑A(X,Y)𝐒𝐞𝐭𝐨𝐢𝐝𝐅A(X,Y).

Every A-set defines an A-setoid as follows.

Definition 14.

Let XVA. Define =X:dom(X)×dom(X)A by

x=yX=xXyXx=y (3)

Then (dom(X),=X) is an A-setoid, which we write Oid(X) when we need to be unambiguous. When we speak of elements of Oid(X), we mean elements of the underlying set of Oid(X), i.e. elements of dom(X), following the usual convention for sets with structure.

Definition 15.

Let XVA. For each SVA such that SX=1, then e(S), defined as follows, is a predicate on Oid(X):

e(S)(x)=xS,

where xOid(X). In particular, this holds if Sdom(𝒫A(X)).

Definition 16.

The following defines Oid:𝐒𝐞𝐭A𝐒𝐞𝐭𝐨𝐢𝐝𝐑A a functors, where f:XY is in 𝐒𝐞𝐭A:

Oid(f)(x,y)=(x,y)Af

This functors is full, faithful and essentially surjective, so 𝐒𝐞𝐭A𝐒𝐞𝐭𝐨𝐢𝐝𝐑A.

Theorem 17.

For each XVA, Oid(𝒫A(X)) is complete. Moreover, if Φ is a formula of 𝔏𝐒𝐞𝐭(VA) and S𝒫A(X).Φ(S,)=aA, then there exists SOid(𝒫A(X)) such that Φ(S,)=a.

Corollary 18.

For each X,YVA, Oid(𝒫A(X×AY)) and Oid({X𝐴Y}) are complete, and if we prove a relation or a function exists in the Boolean-valued sense, satisfying some formula Φ𝔏𝐒𝐞𝐭(VA), then there exists a corresponding element of Oid(𝒫A(X×AY)) or Oid({X𝐴Y}) satisfying Φ.

4 Models of Untyped Lambda-calculus in Boolean-valued sets

In this section we show how to model untyped λ-calculus in A-valued sets. We use the Engeler model [11] as the main example. We will repeatedly use Theorem 1 to prove statements in VA by proving them in set theory first. The reader who would prefer to use a topos formulation might prefer to use the categorical formulation of the Engeler model from [18].

4.1 Background on Domain Theory

A dcpo (D,) is a poset that is directed complete, i.e. such that every directed set has a supremum. Every complete lattice is a dcpo. The least element of a dcpo (D,), if it exists, is called the bottom element and is written . In a dcpo D, where d,eD, we say that d is way below e, written de, if for each directed set (ei)iI such that eiIei, there exists some jI such that dej. The relation is transitive and antisymmetric, but in general is neither reflexive nor irreflexive. We write d={eDed}. A dcpo D is called continuous if for all dD, the set d is directed and d=d. A continuous dcpo is called a domain. A complete lattice that is continuous as a dcpo is called a continuous lattice. A basis or base for a domain D is a subset BD such that for all dD, dB is directed, and d=(dB). It follows that if D is continuous, then D is a base for D. If D has a countable base, we say it is a countably-based domain. See [14] for more related concepts.

If D and E are dcpos, a function f:DE is said to be Scott continuous if it is monotone and preserves directed suprema. We write [DE] for the set of Scott-continuous maps DE. This is a dcpo when given the pointwise ordering, and directed suprema are calculated pointwise. When we refer to this as a dcpo, we always use this structure. The Scott topology on a dcpo D is the topology whose open sets are the sets UD such that U is an up set and for all directed sets (di)iI such that iIdiU there exists iI such that diU. If D and E are dcpos, a function f:DE is Scott continuous iff it is a continuous map from D to E equipped with their respective Scott topologies.

Definition 19.

A reflexive dcpo is a triple (D,𝐟𝐮𝐧,𝐥𝐚𝐦), where D is a dcpo with bottom888This is what is meant by a cpo in [4, Definition 1.2.1 (ii)]., and 𝐟𝐮𝐧:D[DD] and 𝐥𝐚𝐦:[DD]D are Scott-continuous maps making [DD] a retract of D, i.e. 𝐟𝐮𝐧𝐥𝐚𝐦=id[DD]. A reflexive dcpo is extensional iff 𝐟𝐮𝐧, or equivalently 𝐥𝐚𝐦 is an isomorphism, i.e. iff additionally 𝐥𝐚𝐦𝐟𝐮𝐧=idD.

It is often convenient to formulate this notion using the uncurried form of 𝐟𝐮𝐧, which is to say, we can equivalently define a reflexive dcpo to be a triple (D,,𝐥𝐚𝐦) where D is a dcpo with bottom, and :D×DD and 𝐥𝐚𝐦:[DD]D are Scott-continuous maps such that for each f[DD] and dD we have 𝐥𝐚𝐦(f)d=f(d).

The language of untyped λ-calculus can be interpreted in a reflexive dcpo as follows. Given a reflexive dcpo (D,,𝐥𝐚𝐦), and a set of variables Var, a valuation is a partial function ρ:VarD. We also choose a set of constants 𝔎D, which is allowed to be any subset, including and D itself. We then define the language of λ-calculus Λ(D,Var,𝔎) as follows.

Definition 20.

The language Λ(D,Var,𝔎) is defined inductively by the rules

We write Λ(Var) for Λ(D,Var,), since this does not depend on D. The elements of Λ(Var) are called pure λ-terms. We write fv(M) for the set of free variables of M, defined as usual.

We make the following observation about how the above definition is formulated in set theory999This is needed to make the proof of Proposition 22 and later results that deal with viewing the syntax of λ-calculus from inside VA more comprehensible. .

Example 21.

There exist Δ0 formulas Λ(D,Var,𝔎)-inductive and Λ(Var)-inductive, such that the sets Λ(D,Var,𝔎) and Λ(Var) are respectively definable as the smallest sets satisfying their corresponding formula.

Indeed, to define Λ(Var)-inductive and Λ(D,Var,𝔎)-inductive, we need a way to represent the syntax of λ-calculus. For example, we could take the ordinals 0 to mean a variable, 1 a λ-abstraction, 2 an application and 3 a constant, so that a variable appears as (0,x) for xVar, a λ-abstraction as (1,(x,M)) where xVar and M is a λ-term, an application as (2,(M,N)) where M,N are λ-terms, and a constant as (4,d) where d𝔎.

Then we can define:

Λ(Var)-inductive(X) =(xVar.pX.p=(0,x))
(xVar.MX.pX.p=(1,(x,M)))
(MX.NX.pX.p=(2,(M,N))).

Strictly speaking this is not quite a Δ0 formula, but it is not difficult to see that the statements p=(0,x), p=(1,(x,M)) and p=(2,(M,N)) are expressible as Δ0 formulas (with the usual set-theoretic representations of ordered pairs). Then, we define:

Λ(D,Var,𝔎)-inductive(X)=Λ(Var)-inductive(X)(d𝔎.pX.p=(3,d))

Then, Λ(Var) and Λ(D,Var,𝔎) are the least sets satisfying their respective formulas.

Proposition 22.

Let Var be a set101010Not Boolean-valued, just the usual kind of set.. For any complete Boolean algebra A, there exists111111By Theorem 1 (i) and (iii). Λ(Varˇ)A that satisfies the definition of Λ(Varˇ) in the Boolean-valued sense, i.e.

(Λ(Varˇ)-inductive(Λ(Varˇ)A)=1

and for all XVA such that Λ(Varˇ)-inductive(X)=1, we have Λ(Varˇ)AX=1.
Then Λ(Var)ˇ=Λ(Varˇ)A=1.

The equational theory of λ-calculus, called 𝝀 is described following [4]:

Definition 23.

Sentences of 𝛌 are of the form M=N, where M,NΛ(Var). The theory 𝛌 is generated by the following rules, under modus ponens and α-conversion.

  1. (i)

    (λx.M)N=M[x:=N], where M[x:=N] is capture-avoiding substitution of N for x.

  2. (ii)

    M=M.

  3. (iii)

    M=NN=M.

  4. (iv)

    M=N,N=LM=L.

  5. (v)

    M=NMZ=NZ.

  6. (vi)

    M=NZM=ZN.

  7. (vii)

    M=Nλx.M=λx.N.

We write 𝝀M=N to say that the equation M=N is derivable in the theory 𝝀.

Example 24.

Here is a brief description of the set-theoretic formulation of 𝛌. We can simply consider it to be a subset of Λ(Var)×Λ(Var), and interpret 𝛌M=N as (M,N)𝛌. We can define a formula 𝛌-inductive(S), which we no longer require to be Δ0, that encodes the rules of forming 𝛌 from Definition 23, and then 𝛌 can be characterized as the least set (with respect to ) such that 𝛌-inductive(𝛌). This allows us to define 𝛌A in VA.

We can then prove that 𝛌ˇ𝛌A=1 by induction on the structure of an element of 𝛌.

Definition 25.

Following [4, Definition 5.4.2], we define the interpretation of λ-terms from MΛ(D,Var,𝔎) in D, using a valuation ρ such that fv(M)dom(ρ), by

xρ =ρ(x) xVar
kρ =k k𝔎
MNρ =MρNρ
λx.Mρ =𝐥𝐚𝐦(λd.Mρ(x:=d)),

where λ is the “meta-lambda”, and ρ(x:=d) is the partial function where dom(ρ(x:=d))=dom(ρ){x} and

ρ(x:=d)(y)={ρ(y)if ydom(ρ){x}dif y=x

This is proved to define a model of λ-calculus in [4, Theorem 5.4.4], which is to say, that for all M,NΛ(D,Var), if 𝛌M=N, then for all valuations ρ, Mρ=Nρ. For closed terms MΛ(D,Var,𝔎), we write M for M.

We now give the Boolean-valued version.

Theorem 26.

Let DVA such that the A-setoid of D is strict, total and complete, and let there be 𝐥𝐚𝐦 and in VA such that (D,𝐥𝐚𝐦,) is a reflexive dcpo=1. And take Var to be a set of variables and 𝔎VA such that 𝔎D=1 an A-set of constants. Then for each ρ that defines a partial function from Varˇ to D, there are functions -ρA𝐒𝐞𝐭𝐨𝐢𝐝𝐅A(Λ(D,Varˇ,𝔎)A,D) and -ρA𝐒𝐞𝐭𝐨𝐢𝐝𝐅A(Λ(Var)ˇ,D) satisfying Definition 25 in the A-valued sense.

Furthermore, for all M,NΛ(Var), if 𝛌M=N, then for all ρ we have Mˇρ=Nˇρ.

4.2 The Engeler Model

We start with a basic result about the power set.

Proposition 27.

For any set X, the power set 𝒫(X), when ordered using the subset relation , is a dcpo (in fact, a complete lattice). If S,T𝒫(X), ST iff S is finite and ST. The set of finite sets 𝒫fin(X) is a base, and if X is countable, it is a countable base.

We can then apply this in VA as follows.

Proposition 28.

For any XVA, the A-set 𝒫A(X), ordered with the subset relation, is a continuous lattice with base 𝒫finA(X), interpreted in the A-valued sense. As an A-setoid, 𝒫A(X) is complete and total. If X=Yˇ, then 𝒫fin(Y)ˇ is a base, and 𝒫A(Yˇ) is strict.

We define the Engeler model [11, 4], an adaptation of the Scott-Plotkin graph model that uses set-theoretic operations instead of Gödel numbering, as follows121212What we really need of E is for it to be countable, non-empty, and an algebra of the functor 𝒫fin×Id, such that the structure map 𝒫fin(E)×EE is injective, which implies E must be infinite. We cannot use the initial algebra of 𝒫fin×Id, because it is ..

Let E0={}. We define En+1=(𝒫fin(En)×En)En and E=n=0En. Then we have a map (-,-):𝒫fin(E)×EE defined by pairing, since for each S𝒫fin(E) we have SEn for some n. For reasons that will become clear later, we express the existence of the Engeler model in the following manner.

Proposition 29.

Let E be a set equipped with an injective mapping (-,-):𝒫fin(E)×EE. Define 𝐥𝐚𝐦:[𝒫(E)𝒫(E)]𝒫(E) and --:𝒫(E)×𝒫(E)𝒫(E) by

𝐥𝐚𝐦(f) ={(K,q)qf(K)}={xEK𝒫fin(E),qf(K).x=(K,q)}
FX ={qEK𝒫fin(E).KX and (K,q)F},

where f[𝒫(E)𝒫(E)], and F,X𝒫(E). Then (𝒫(E),,𝐥𝐚𝐦) is a reflexive dcpo.

We can now build the Engeler model in VA, as follows.

Theorem 30.

Let E be the set defined before Proposition 29. (𝒫A(Eˇ),,,𝐥𝐚𝐦) is an A-valued reflexive dcpo, where and 𝐥𝐚𝐦 are defined by the A-valued interpretation of the definitions given in Proposition 29.

By combining Theorem 30 with Proposition 28 and Theorem 26, we obtain a function -A that interprets λ-terms in a manner that respects provable equations between them.

The following lemma shows that if we only use pure λ-terms we do not get anything new by using 𝒫A(Eˇ) instead of 𝒫(E) as a model of λ-calculus.

Lemma 31.

Let MΛ(Var) and ρ a valuation such that fv(M)dom(ρ), and consider -A and - as defined for 𝒫A(Eˇ) and 𝒫(E) respectively. Then MˇρˇA=Mρˇ=1.
In particular, since =ˇ, if M is closed we have MˇA=Mˇ=1.

4.3 Injective Spaces and Oracles

We can encode the Booleans {,}, and natural numbers in λ-calculus in several ways, e.g. with the Church numerals. The details of the encoding do not matter, only the following.

Definition 32.

Let (D,𝐟𝐮𝐧,𝐥𝐚𝐦) be a reflexive dcpo, and let , be closed λ-terms and (cn)n a family of closed λ-terms. We say (D,𝐟𝐮𝐧,𝐥𝐚𝐦,,,(cn)n) is a reflexive dcpo with numerals if

  1. (i)

    and are distinct elements of D.

  2. (ii)

    There exists a closed λ-term 𝐢𝐟 such that for all λ-terms M,N, 𝝀𝐢𝐟MN=M and 𝝀𝐢𝐟MN=N.

  3. (iii)

    There exist closed λ-terms 𝐬𝐮𝐜𝐜 and 𝐩𝐫𝐞𝐝 representing the successor and predecessor operations on (cn)n, i.e. for all n, 𝝀𝐬𝐮𝐜𝐜cn=cn+1 and 𝝀𝐩𝐫𝐞𝐝cn+1=cn and 𝝀𝐩𝐫𝐞𝐝c0=c0.

  4. (iv)

    There exists a closed λ-term 𝟎? such that 𝝀𝟎?c0= and for all n>0, 𝝀𝟎?cn=.

Proposition 33.

The Church Booleans and Church numerals make the Engeler model into a reflexive continuous lattice with numerals.

Corollary 34.

The Engeler model in VA, as described in Theorem 30, is a reflexive continuous lattice with numerals, when given (-ˇ of) the Church Booleans and Church numerals, with this whole statement being interpreted in VA.

In the following, for a set A, we write χA for the function A2 such that χA(x)={1if xA0if xA,
while if {,} are part of the structure of a reflexive dcpo with numerals D, we write χAD for the function {,} such that:
χAD(x)={if xAif xA.

Every dcpo is a T0 topological space when equipped with its Scott topology [14]. And a T0 topological space X is injective for subspace embeddings in the category of T0-spaces iff X is a continuous lattice equipped with the Scott topology [27]. This has useful consequences for representations of the natural numbers in reflexive dcpos that are continuous lattices.

Lemma 35.

Let (D,𝐟𝐮𝐧,𝐥𝐚𝐦,,,(cn)n) be a reflexive dcpo with numerals. Then:

  1. (i)

    {,} and {cn}n are discrete in the Scott topology of D, and also are distinct elements, i.e. cm=cn implies m=n.

If D is additionally a continuous lattice, then:

  1. (ii)

    For every set A, there is a dgD such that for all n, dgcn=χAD(n).

We can now define a pre-order on sets of integers to be used in the example (Theorem 43). Readers familiar with recursion theory will see that it is the λ-calculus version of comparability of many-one degrees [29, Definition 4.8 (i), (iii)].

Proposition 36.

Let D be a reflexive continuous lattice with numerals. The following are equivalent for S1,S2, in which case we write S1mS2:

  1. (i)

    There exists a closed λ-term MΛ(D,Var) such that for all n, there exists m such that 𝝀Mcn=cm, and there exist dS1,dS2D such that for all n, dS1cn=χS1D(n), dS2cn=χS2D(n) and dS2(Mcn)=dS1cn.

  2. (ii)

    There exists a closed λ-term MΛ(D,Var) such that for all n, there exists m such that 𝝀Mcn=cm, and for all dS1,dS2D such that for all n, dS1cn=χS1D(n) and dS2cn=χS2D(n), we have that for all n, dS2(Mcn)=dS1cn.

5 Random Variables

In this section we relate the Boolean-valued Engeler model in VA from Corollary 34 to the random-variable-based Boolean-valued models of λ-calculus from [3], and give the example application (Theorem 43).

We start with some terminology. A negligibility space (X,Σ,𝒩) is a measurable space (X,Σ) equipped with a σ-ideal 𝒩 such that Σ/𝒩 is a complete Boolean algebra, not just σ-complete. We use A(X) to denote Σ/𝒩, as it is the complete Boolean algebra associated to X or simply the algebra associated to X.

For a probability space (X,Σ,μ), the null ideal 𝒩(μ) is the σ-ideal of sets NΣ with μ(N)=0, and Σ/𝒩(μ) is a complete Boolean algebra [13, 322B,322C], so (X,Σ,𝒩(μ)) is a negligibility space, and Σ/𝒩(μ) is known as the measure algebra of (X,Σ,μ).

Let Y be a countable set. For each yY, let By={SYyS}, which form a subbasis of open sets for the positive topology131313The positive topology equals the Scott topology. on 𝒫(Y). All notions of measurability for 𝒫(Y) will be with respect to the Borel σ-algebra defined by this topology, and since this is a second countable topology, (By)yY is also a countable generating set for this σ-algebra.

Definition 37.

Let X=(X,ΣX) be a measurable space and Y a countable set. We define 0(X;𝒫(Y)) to be the set of measurable functions X𝒫(Y), using the Borel σ-algebra of the Scott topology of 𝒫(Y). We define a ΣX-valued order as follows:

ab0={xXa(x)b(x)}.

The corresponding notion of equality is

a=b0={xXa(x)=b(x)}.
Lemma 38.

If X=(X,ΣX,𝒩X) is a negligibility space, define L0(X;𝒫(Y)) to be 0(X;𝒫(Y)) modulo the relation defined by: ab iff Xa=b0𝒩X, which is the usual “almost everywhere” equivalence. Then L0 and =L0, defined by composing the corresponding notions for 0(X;𝒫(Y)) with [-]:ΣA(X), are well-defined and make L0(X;𝒫(Y)) into an A(X)-poset.

We define GX:L0(X;𝒫(Y))𝒫A(X)(Yˇ) as follows, where a0(X;𝒫(Y)) and yY:

GX([a])(yˇ)=[a1(By)]=[{xXya(x)}] (4)

The measurability of a guarantees that a1(By)Σ.

Proposition 39.

For any negligibility space (X,Σ,𝒩) and any countable set Y, the map GX is a strict isomorphism of A(X)-posets L0(X;𝒫(Y))𝒫A(X)(Yˇ).

Since 𝒫(E) is a reflexive dcpo and has a binary operation for application, for any measurable space X we can extend this pointwise to 0(X;𝒫(E)) by defining for a,b0(X;𝒫(E)) and xX: (ab)(x)=a(x)b(x).
For a negligibility space X we can then extend this to L0(X;𝒫(E)) by defining [a][b]=[ab].

Proposition 40.

Let (X,Σ,𝒩) be a negligibility space. Then the above definition of :L0(X;𝒫(E))×L0(X;𝒫(E))L0(X;𝒫(E)) is well-defined, and GX:L0(X;𝒫(E))𝒫A(X)(Eˇ) is an “application homomorphism”, i.e. for all [a],[b]L0(X;𝒫(E)),

GX([a][b])=GX([a])GX([b]).

We now introduce the following notation. If SE, define KS0(X;𝒫(E)) to be the function taking the constant value S. This relates to -ˇ in the following way.

Lemma 41.

Let Y be an arbitrary countable set. For all SY we have

GX([KS])=Sˇ=1

Recall that a subbase of clopens for the product topology of 2ω is given by the sets (Cn,b)nω,b2, where Cn,b={f2ωf(n)=b}.
These sets also generate the Borel σ-algebra of 2ω.

In the following, we will also have to consider the (isomorphic) product space 2ω×2ω, but for which we will need to describe the subsets in more detail. So for i{1,2}, nω and b2 we write Di,n,b={(f1,f2)2ω×2ωfi(n)=b}.
Then for all i{1,2}, nω and b2 we have Di,n,b=πi1(Cn,b).

Let X=2ω×2ω equipped with its Borel σ-algebra as a measurable space. We define μX to be the usual independent fair coin measure, which is to say, it is the unique measure such that for all finitely-supported partial functions f1,f2:ω2

μ(ndom(f1)D1,n,f1(n)ndom(f2)D2,n,f2(n))=2(|dom(f1)|+|dom(f2)|).

We take the null ideal of this measure as the negligible sets of X. Then π1,π2 are random variables in 0(X;2ω). They define S1,S2𝒫A(X)(ωˇ) as follows, taking i{1,2}:

Si(nˇ)=[πi1(Cn,1)]=[Di,n,1]. (5)

We remind the reader at this point that nˇSi=Si(nˇ) because of the way Boolean-valued equality behaves for elements of ωˇ.

Proposition 42.

For all f:ωω, neither S1 nor S2 is the preimage of a finite A(X)-subset of ωˇ, i.e. K𝒫finA(X)(ωˇ).nωˇ.nS1fˇ(n)K=0, and likewise for S2.
Moreover, S1=fˇ1(S2)=0 and S2=fˇ1(S1)=0, i.e. these sets cannot be mapped to each other by any classical function.

Theorem 43.

There exist sets T1,T2 such that neither can be mapped to the other by a λ-definable function, i.e. we neither have T1mT2 nor T2mT1 (recall Proposition 36).

Proof.

We start by doing Boolean-valued reasoning about S1 and S2, taking A=A(2ω×2ω), and use the fact that the Engeler model 𝒫A(Eˇ) is (A-valuedly) a reflexive continuous lattice with numerals (Corollary 34) and Proposition 36.

First, by Theorem 1 applied to Lemma 35 (ii), there exist d1,d2𝒫A(Eˇ) such that for all nω and i{1,2} we have dicnˇ=ˇ=nˇSi and dicnˇ=ˇ=¬nˇSi.

Suppose MΛ(Var) such that for all nω, there exists mω such that 𝝀Mcn=cm. In particular, there exists some function f:ωω such that for all mω, 𝝀Mcn=cf(n).

Now we consider d2(Mˇcˇn)A and d1cˇnA. In the following, for ease of notation, we write an equals sign to mean the corresponding A-valued equality being equal to 1:
d2(Mcnˇ)A=d2McnˇA=d2cf(n)ˇA by Theorem 26. Therefore,
d2(Mcnˇ)A=ˇA=d2cf(n)ˇA=ˇA=f(n)ˇS2, and the corresponding negative statement for . Likewise, d1cˇnA=ˇ=nˇS1, and the corresponding statement for . So all together, d2McnˇA=d1cˇnA=f(n)ˇS2nˇS1.
It is proved in Proposition 42 that nωˇ.fˇ(n)S2nS1=0, so we can conclude that nωd2McnˇA=d1cˇnA=0 for all MΛ(Varˇ) that map numerals to numerals.

Let a1,a20(X;𝒫(E)) s.t. for i{1,2} we have [ai]=GX1(di). Then, using Proposition 39, Proposition 40, Lemma 31 and Lemma 41, we get:
0=nωGX1(d2McnˇA)=GX1(d1cˇnA)L0
=nωGX1(d2)GX1(McnˇA)=GX1(d1)GX1(cˇnA)L0
=nω[a2]GX1(Mcnˇ)=[a1]GX1(cnˇ)L0=nω[a2][KMcn]=[a1][Kcn]L0
=[nω{xXa2(x)KMcn(x)=a1(x)Kcn(x)}]
=[{xXnω.a2(x)Mcn=a1(x)cn}],
so the set inside the square brackets has measure zero.

Since the set of MΛ(Var) that map numerals to numerals is countable (because Var is countable), the set of xX such that for all MΛ(Var) mapping numerals to numerals we have a2(x)Mcna1(x)cn has measure 1.

For all i{1,2}, we have, by the definition of di, for all nω the statement dicnA=AdicnA=A=1. By a similar argument to that used above, this means that the set of xX such that ai(x)cn{,} has measure 1, and by the countability of ω the set where this is true for both i{1,2} and all nω is also of measure 1.

Therefore the intersection of the sets defined in the previous two paragraphs has measure 1, and so is non-empty and so there exists a point x in it. We can then define Ti={nωai(x)cn=}, and we have proved, by Proposition 36, that T1mT2.

We could not have done this proof by using the “fact” that L0(X;𝒫(E)) is a continuous dcpo, because this is not true, as stated in our last proposition.

Proposition 44.

Let X=(X,Σ,𝒩) be a negligibility space such that A(X) is not atomic, and let Y be a non-empty countable set. Then L0(X;𝒫(Y)) is not a continuous dcpo.

6 Conclusions

We have developed domain theory in a Boolean-valued universe of sets. Using the measure algebra as the Boolean algebra we obtained a domain of random variables which can be see to be a reflexive domain in the internal language of the Boolean-valued set theory. We have focused on the pure λ-calculus here but it should be straightforward to extend this to a λ-calculus with probabilistic choice as an explicit primitive.

There are a number of directions for future work. First, one can use this construction to give semantics to a λ-calculus extended with probabilistic choice as was done in [3]. In this model it will be interesting to see which equations involving the interplay of choice and the standard λ-calculus constructions are valid. One could then relate it to an operational semantics as, for example, in [8] but one would need a Boolean-valued notion of operational semantics. More interestingly one could define conditioning as a primitive and explore its semantics. A second line of research is the notion of approximation. A notion of “approximate equality” has been developed recently [22]; the connection to the notion of equality used in the present paper is unclear but there is a similarity in that in both cases equality may only hold partially.

References

  • [1] Nathanael L. Ackerman, Cameron E. Freer, and Daniel M. Roy. Noncomputable conditional distributions. In Logic in Computer Science (LICS), 2011 26th Annual IEEE Symposium on, pages 107–116. IEEE, 2011. doi:10.1109/LICS.2011.49.
  • [2] Nathanael L. Ackerman, Cameron E. Freer, and Daniel M. Roy. On the computability of conditional probability. J. ACM, 66(3):23:1–23:40, 2019. doi:10.1145/3321699.
  • [3] Giorgio Bacci, Robert Furber, Dexter Kozen, Radu Mardare, Prakash Panangaden, and Dana Scott. Boolean-valued semantics for the stochastic λ-calculus. In Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science, pages 669–678. ACM, 2018. doi:10.1145/3209108.3209175.
  • [4] Henk P. Barendregt. The Lambda Calculus: Its Syntax and Semantics. North-Holland, Amsterdam, 1984.
  • [5] John L. Bell. Set Theory: Boolean-Valued Models and Independence Proofs, volume 47 of Oxford Logic Guides. Oxford University Press, third edition, 2005.
  • [6] Johannes Borgström, Ugo Dal Lago, Andrew D. Gordon, and Marcin Szymczak. A lambda-calculus foundation for universal probabilistic programming. In Jacques Garrigue, Gabriele Keller, and Eijiro Sumii, editors, Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, Nara, Japan, September 18-22, 2016, pages 33–46. ACM, 2016. doi:10.1145/2951913.2951942.
  • [7] Fredrik Dahlqvist and Dexter Kozen. Semantics of higher-order probabilistic programs with conditioning. Proc. ACM Program. Lang., 4(POPL):57:1–57:29, 2020. doi:10.1145/3371125.
  • [8] Pedro H. Azevedo de Amorim, Dexter Kozen, Radu Mardare, Prakash Panangaden, and Michael Roberts. Universal semantics for the stochastic λ-calculus. In Proceedings of the ACM-IEEE Symposium on Logic in Computer Science, 2021. arXiv preprint:2011.13171.
  • [9] Thomas Ehrhard, Michele Pagani, and Christine Tasson. Measurable cones and stable, measurable functions: a model for probabilistic higher-order programming. Proceedings of the ACM Symposium on Principles of Programming Languages, 2(POPL):1–28, 2017. doi:10.1145/3158147.
  • [10] Thomas Ehrhard, Christine Tasson, and Michele Pagani. Probabilistic coherence spaces are fully abstract for probabilistic pcf. In Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 309–320, 2014. doi:10.1145/2535838.2535865.
  • [11] Erwin Engeler. Algebras and Combinators. Algebra Universalis, 13(1):389–392, December 1981. doi:10.1007/BF02483849.
  • [12] Michael P. Fourman and Dana S. Scott. Sheaves and Logic. In Michael Fourman, Christopher Mulvey, and Dana Scott, editors, Applications of Sheaves: Proceedings of the Research Symposium on Applications of Sheaf Theory to Logic, Algebra, and Analysis, Durham, July 9–21, 1977, pages 302–401. Springer Berlin Heidelberg, 1979. doi:10.1007/BFb0061824.
  • [13] David H. Fremlin. Measure Theory, Volume 3. https://www.essex.ac.uk/maths/people/fremlin/mt.htm, 2002.
  • [14] Gerhard Gierz, Karl H. Hofmann, Klaus Keimel, Jimmie D. Lawson, Michael W. Mislove, and Dana S. Scott. Continuous Lattices and Domains, volume 93 of Encyclopedia of Mathematics and its Applications. Cambridge University Press, 2003.
  • [15] Robert Goldblatt. Topoi: The Categorial Analysis of Logic. Dover, 2006.
  • [16] Noah Goodman, Vikash Mansingkha, Daniel Roy, Keith Bonawitz, and Joshua Tenenbaum. Church: a language for generative models. In Proceedings of the 24th Conference on Uncertainty in Artificial Intelligence, pages 220–229, 2008.
  • [17] Chris Heunen, Ohad Kammar, Sam Staton, and Hongseok Yang. A convenient category for higher-order probability theory. In Proceedings of the Thirty-second Annual ACM-IEEE Symposium on Logic in Computer Science, pages 1–12, 2017. doi:10.1109/LICS.2017.8005137.
  • [18] Martin Hyland, Misao Nagayama, John Power, and Giuseppe Rosolini. A Category Theoretic Formulation for Engeler-style Models of the Untyped λ-Calculus. Electronic Notes in Theoretical Computer Science, 161:43–57, 2006. Proceedings of the Third Irish Conference on the Mathematical Foundations of Computer Science and Information Technology (MFCSIT 2004). doi:10.1016/j.entcs.2006.04.024.
  • [19] Thomas J. Jech. Set Theory. Springer, 3rd Millennium edition, 2003.
  • [20] Stephen C. Kleene and Emil L. Post. The Upper Semi-Lattice of Degrees of Recursive Unsolvability. Annals of Mathematics, 59(3):379–407, 1954. doi:10.2307/1969708.
  • [21] Anatoly G. Kusraev and Semën S. Kutateladze. Boolean Valued Analysis, volume 494 of Mathematics and Its Applications. Springer, 1999. doi:10.1007/978-94-011-4443-8.
  • [22] Radu Mardare, Prakash Panangaden, and Gordon Plotkin. Quantitative algebraic reasoning. In Proceedings of the 31st Annual ACM-IEEE Symposium on Logic in Computer Science, pages 700–709, 2016. doi:10.1145/2933575.2934518.
  • [23] Gordon P. Monro. A Category-theoretic Approach to Boolean-valued Models of Set Theory. Journal of Pure and Applied Algebra, 42(3):245–274, 1986. doi:10.1016/0022-4049(86)90010-1.
  • [24] Gordon P. Monro. Quasitopoi, Logic and Heyting-valued Models. Journal of Pure and Applied Algebra, 42(2):141–164, 1986. doi:10.1016/0022-4049(86)90077-0.
  • [25] Dan Roy. Computability, inference and modeling in probabilistic programming. PhD thesis, MIT, June 2011.
  • [26] Dana Scott. A proof of the independence of the continuum hypothesis. Mathematical Systems Theory, 1(2):89–111, 1967. doi:10.1007/BF01705520.
  • [27] Dana Scott. Continuous Lattices. In F. William Lawvere, editor, Toposes, Algebraic Geometry and Logic, pages 97–136. Springer Berlin Heidelberg, 1972. doi:10.1007/BFb0073967.
  • [28] Dana Scott. Stochastic λ-calculi. Journal of Applied Logic, 12(3):369–376, 2014.
  • [29] Robert I. Soare. Recursively Enumerable Sets and Degrees. Perspectives in Mathematical Logic. Springer, 1987.
  • [30] Clifford Spector. Measure-Theoretic Construction of Incomparable Hyperdegrees. Journal of Symbolic Logic, 23(3):280–288, September 1958. doi:10.2307/2964288.
  • [31] Sam Staton, Hongseok Yang, Frank Wood, Chris Heunen, and Ohad Kammar. Semantics for probabilistic programming: higher-order functions, continuous distributions, and soft constraints. In Proceedings of the 31st Annual ACM-IEEE Symposium On Logic In Computer Science, pages 525–534, 2017.
  • [32] Matthijs Vákár, Ohad Kammar, and Sam Staton. A domain theory for statistical probabilistic programming. Proceedings of the ACM Conference on Principles of Programming Languages, 3(POPL):1–29, 2019. doi:10.1145/3290349.
  • [33] Frank Wood, Jan Willem van de Meent, and Vikash Mansinghka. A new approach to probabilistic programming inference. In Proceedings of the 17th International conference on Artificial Intelligence and Statistics, pages 1024–1032, 2014. URL: http://proceedings.mlr.press/v33/wood14.html.

Appendix A Appendix

Proof of Theorem 1.

For (i) and (ii), see [5, Theorem 1.17]; (iii) is a particular instance of what we shall later call the “completeness” of VA – see [19, Lemma 14.19] or [5, Lemma 1.27].

Proof of Theorem 26.

It follows from Theorem 1 applied to Definition 25 that there exist some elements of VA representing functions -ρA with the required properties holding with Boolean value 1. So by Corollary 18 we can take -ρA𝐒𝐞𝐭A(Λ(D,Varˇ,𝔎)A,D) and also -ρA𝐒𝐞𝐭A(Λ(Var)ˇ,D) for pure terms (using Proposition 22). So by Definition 16, these define maps in 𝐒𝐞𝐭𝐨𝐢𝐝𝐑A(Λ(D,Varˇ,𝔎)A,D) and 𝐒𝐞𝐭𝐨𝐢𝐝𝐑A(Λ(Var)ˇ,D). So by completeness of D, we can apply Definition 13 to get maps in 𝐒𝐞𝐭𝐨𝐢𝐝𝐅A(Λ(D,Varˇ,𝔎)A,D) and 𝐒𝐞𝐭𝐨𝐢𝐝𝐅A(Λ(Var)ˇ,D).

From this, we get that if 𝝀M=N, then (M,N)ˇ𝝀A=1, and therefore for all ρ, Mˇρ=Nˇρ=1. Since D is strict, this implies that actually Mˇρ=Nˇρ in the usual sense as well.

Proof of Proposition 28.

We get the first part by applying Theorem 1 to Proposition 27. By Theorem 17, 𝒫A(X) is complete, and it is clear from its definition that it is total. Now, if X=Yˇ, we use the fact that 𝒫fin(Y)ˇ=𝒫finA(Yˇ)=1 (Proposition 3), so 𝒫fin(Y)ˇ is also a base for 𝒫A(Yˇ) with Boolean value 1.

Finally, to show that 𝒫A(Yˇ) is strict, let S,T𝒫A(Yˇ) such that S=T𝒫A(Yˇ)=1, which is equivalent to S=T=1. First observe that dom(S)=dom(Yˇ)=dom(T), and then that for all yˇdom(Yˇ), we have yˇS=S(yˇ) and likewise for T. Since S=T=1, for all yY we have

S(yˇ)=yˇS=yˇT=T(yˇ),

so S=T.

Proof of Theorem 30.

By Theorem 2, (-,-)ˇ defines an injective function 𝒫fin(E)ˇ×AEˇ=𝒫fin(E)×EˇEˇ. Since 𝒫fin(E)ˇ=𝒫finA(Eˇ)=1 by Prop. 3, it also defines an injective function 𝒫finA(Eˇ)×AEˇEˇ. We apply Theorem 1 (i) to Prop. 29 to conclude that 𝒫A(Eˇ) is a reflexive dcpo.

Proof of Corollary 34.

By Lemma 31, ˇA=ˇ=1, and likewise for and the Church numerals.

Then part (i) of Definition 32 is a Δ0 statement, so it follows by applying Theorem 2 to Proposition 33. Parts (ii) - (iv) then follow by Example 24.

Proof of Lemma 35.

  1. (i)

    As Scott topologies are T0, part (i) of Definition 32 implies that there is a Scott-open set UD containing one of {,} but not the other. We start under the assumption that U and U. This implies that {} is an open subset of the subspace {,}.

    The map 𝐟𝐮𝐧(¬):DD is Scott continuous, and 𝐟𝐮𝐧(¬)()= and vice-versa. So 𝐟𝐮𝐧(¬)1(U) is an open set containing , but not , proving that {} is an open subset of the subspace {,}. This proves that {,} is a discrete subspace of D, and the proof starting with U is similar.

    To prove the discreteness and distinctness of {cn}n, we will need the fact that there exist closed λ-terms 𝐦? such that 𝝀𝐦?cn= if m=n and 𝝀𝐦?cn= otherwise. It is not difficult to prove directly that we can take 𝟏?=λm.𝐢𝐟(𝟎?m)(𝟎?(𝐩𝐫𝐞𝐝m)), and 𝐧?=λm.𝐧𝟏?(𝐩𝐫𝐞𝐝m). It follows that 𝐟𝐮𝐧(𝐧?)(cm)= if n=m and otherwise.

    Now, if mn are elements of , we have 𝝀𝐦?cm=, and 𝝀𝐦?cn=, so 𝐟𝐮𝐧(𝐦?)(cm)==𝐟𝐮𝐧(𝐦?)(cn). As 𝐟𝐮𝐧(𝐦? is a function, it follows that cmcn.

    To prove the discreteness of {cn}n, we show that for all m, the singleton {cm} is relatively open in {cn}n. Let UD be a Scott-open set such that U, but U. Then V=𝐟𝐮𝐧(𝐦?)1(U) is a Scott-open set such that mV but nV for all n such that nm.

  2. (ii)

    Given A, define g:{cn}nD by g(cn)=χAD(n). By the discreteness of {cn}n, proved in the previous part, this is continuous. Since D is a continuous lattice, and therefore injective [27, Theorem 2.12], g extends to a Scott-continuous map g¯:DD, and since (D,𝐥𝐚𝐦,𝐟𝐮𝐧) is a reflexive dcpo we can define dg=𝐥𝐚𝐦g¯, and then for all n:

    dgcn=g¯(cn)=χAD(n).

Proof of Lemma 38.

We prove that ab0 is measurable as follows. First, define γ𝒫(Y)×𝒫(Y) to be the graph of the relation, i.e. γ={(S,T)𝒫(Y)×𝒫(Y)ST}.

ab0=a,b1(γ), so since a,b:X𝒫(Y)×𝒫(Y) is measurable, we only need to show that γ is measurable with respect to the product measurable space structure. We have

γ ={(S,T)𝒫(Y)×𝒫(Y)yY.ySyT}
=yY{(S,T)𝒫(Y)×𝒫(Y)yS or yT}
=yY{(S,T)𝒫(Y)×𝒫(Y)yS}{(S,T)𝒫(Y)×𝒫(Y)yT}
=yY((𝒫(Y)By)×𝒫(Y))(𝒫(Y)×By).

Measurability then follows from the countability of Y.

For the well-definedness of L0, it is clear that if aa and bb, then ab0 and ab0 can only differ where a differs from a or b differs from b, and the set of all such points is in 𝒩X. It is easy to deduce the transitivity (in the sense of Definition 11 (i)) from transitivity of , and part (ii) of the definition of an A(X)-poset follows because aaL0=1 for all aL0(X;𝒫(Y)).

Proof of Proposition 39.

We show that for all a,b0(X;𝒫(Y)), GX([a])GX([b])𝒫A(X)(Yˇ)=[a][b]L0. This shows, in one go, that GX is an A(X)-monotone function and also injective (using the fact that L0(X;𝒫(Y)) is total, i.e. εL0(X;𝒫(Y))([a])=[X] for all a0(X;𝒫(Y))).

We start by expanding the definitions:

GX([a])GX([b])𝒫A(X)(Yˇ)=GX([a])GX([b])
= tdom(GX([a]))tGX([a])tGX([b])=yYGX([a])(yˇ)GX([b])(yˇ)
= yY[{xXya(x)}][{xXyb(x)}]
= [yY{xXya(x) implies yb(x)}]
= [{xXyY.ya(x) implies yb(x)}]
= [{xXa(x)b(x)}]=[a][b]L0.

Since L0(X;𝒫(Y)) is a strict A(X)-setoid, and 𝒫A(X)(Yˇ) is total, implying that GX is an injective function. So to prove that GX is a strict isomorphism, we only need to show that GX is surjective.

Let b𝒫A(X)(Yˇ). For each yY, pick SyΣ such that [Sy]=b(yˇ). Define a function
a:X𝒫(Y) by a(x)={yYxSy}. For each yY, we have

a1(By)={xXa(x)By}={xXya(x)}={xXxSy}=SyΣ.

Since (By)yY generates the Borel σ-algebra of 𝒫(Y), this implies that a is measurable. For all yY, we then have

GX([a])(yˇ)=[a1(By)]=[Sy]=b(yˇ),

and therefore GX([a])=b, as required to prove GX surjective.

Proof of Proposition 40.

In fact, we will prove the first part by deducing it from the second part. So let a,b0(X;𝒫(E)). Then for all qE we have

(GX([a])GX([b]))(qˇ)
= K𝒫finA(X)(Eˇ).KGX([b]) and (K,qˇ)A(X)GX([a])
= K𝒫fin(E)ˇ.KGX([b]) and (K,qˇ)A(X)GX([a]) Proposition 3
= K𝒫fin(E)KˇGX([b])(K,q)ˇGX([a])
= K𝒫fin(E)GX([a])((K,q)ˇ)kKGX([b])(kˇ)
= K𝒫fin(E)[{xX(K,q)a(x)}]kK[{xXkb(x)}]
= K𝒫fin(E)[{xX(K,q)a(x)}][{xXKb(x)}]
= [{xXK𝒫fin(E).Kb(x) and (K,q)a(x)}] as 𝒫fin(E) countable
= [{xXqa(x)b(x)}]
= GX([ab])(qˇ),

so all together we have proved that GX([a])GX([b])=GX([ab]). In passing, we have proved that for all qE, (ab)1(Bq) is measurable, and therefore that ab0(X;𝒫(E)).

If a,b0(X;𝒫(E)) such that [a]=[a] and [b]=[b], then by Proposition 39 and the fact that 𝒫A(X)(Eˇ) is a strict A(X)-setoid:

GX([ab])=GX([a])GX([b])=GX([a])GX([b])=GX([ab]),

and therefore [ab]=[ab], so the definition [a][b]=[ab] genuinely defines a function L0(X;𝒫(E))×L0(X;𝒫(E))L0(X;𝒫(E)). Putting this together with what we proved above gives us GX([a])GX([b])=GX([a][b]).

Proof of Lemma 41.

It suffices to show that for all yY, yˇGX([KS])=yˇSˇ. We have

yˇGX([KS])=GX([KS])(yˇ)=[{xXyKS(x)}]=[{xXyS}]=yˇSˇ.

Proof of Proposition 44.

First, let p={aA(X)a an atom}. As A(X) is not atomic, ¬p0, so there is a set SΣ such that S𝒩 and [S]=¬p. By definition there are no atoms below [S]. Define

b(x)={Yif xSotherwise,

where xX. This defines a measurable function X𝒫(Y). As S𝒩, [b][K]. We show that L0(X;𝒫(Y)) is not continuous by showing that [b] is not the supremum of elements way below it, which will follow from the fact that the only element of L0(X;𝒫(Y)) that is way below [b] is [K].

If the only element below [b] is [K], then we are finished, so we reduce to the case that there is at least one [a]L0(X;𝒫(Y)) such that [K]<[a]<[b]. Define T=a1(𝒫(Y){}), which is in Σ because a is measurable and 𝒫(Y){}=yYBy and is therefore a Borel set. We have TS𝒩, so we redefine T to be TS if necessary to make TS.

Since there are no atoms below [S], there are none below [T] either, so there exists a non-zero element a1A(X) such that a1[T] and a1 has no atoms below it. We can repeat this argument to form a strictly descending sequence (ai)i where for all i, ai has no atoms below it and ai[T]. We can define bi=aii=1ai, to get such a strictly decreasing sequence (bi)i, now with i=1bi=0. Since A(X)=Σ/𝒩, we can find a sequence (Vi)i of elements of Σ such that for all i, [Vi]=bi, and by adjusting negligible sets it can be arranged that (Vi)i is also strictly descending. Defining Ti=TUi, then (Ti)i is strictly increasing with respect to , maps to a strictly increasing sequence under [-], and Ti=1Ti𝒩. Define, for each i, ci:X𝒫(Y) as follows:

ci(x)={Yif xTiSTif xTTiXS,

where xX. Each ci is measurable for the same reasons that b is, and ([ci])i is a strictly increasing sequence in L0(X;𝒫(Y)). Since for all i, ci(x)= for all xTTi and TTi𝒩, while a(x) for all xTTTi, we have [a][ci]. But i=1[ci]=[i=1ci]=[b] because Ti=1Ti𝒩. Therefore a is not way below b.