Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an...

34
Order-Theoretic Semantics for ProbNetKAT * 1 Notation and Definitions We use lower case letters a, b, c H to denote history sets, uppercase letters A,B,C 2 H to denote (measurable) sets (i.e., sets of history sets), and calli- graphic letters B, O, ···⊆ 2 2 H to denote sets of measurable sets. For a set X, we let ω (X) , {Y X ||Y | < ∞} denote the finite subsets of X and 1 X the characteristic function of X. For a statement ϕ, we let [ϕ] , ( 1 if ϕ is true 0 otherwise For a function f : X Y , we let f -1 :2 Y 2 X denote the set function f -1 (A) , {x X | f (x) A} f -1 (y) , f -1 ({y}) For h H and b 2 H , define B h , {c | h c} B b , \ hb B h = {c | b c}. (1.1) Then B h = B {h} . The sets B h and B h are the subbasic open sets of the Cantor space topology on 2 H . The family of Borel sets B is the smallest σ- algebra containing the Cantor-open sets. Let B b be the Boolean subalgebra of B generated by {B h | h b}. Lemma 1. (i) b c B c B b (ii) B b B c = B bc (iii) B =2 H * Technical notes for the publication “Cantor Meets Scott: Foundations for Probabilistic Networks.” Steffen Smolka, Praveen Kumar, Nate Foster, Dexter Kozen, and Alexandra Silva. In POPL 2017, Paris. 1

Transcript of Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an...

Page 1: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Order-Theoretic Semantics for ProbNetKAT∗

1 Notation and Definitions

We use lower case letters a, b, c ⊆ H to denote history sets, uppercase lettersA,B,C ⊆ 2H to denote (measurable) sets (i.e., sets of history sets), and calli-

graphic letters B,O, · · · ⊆ 22H

to denote sets of measurable sets. For a set X,we let ℘ω(X) , {Y ⊆ X | |Y | <∞} denote the finite subsets of X and 1X thecharacteristic function of X. For a statement ϕ, we let

[ϕ] ,

{1 if ϕ is true

0 otherwise

For a function f : X → Y , we let f−1 : 2Y → 2X denote the set function

f−1(A) , {x ∈ X | f(x) ∈ A} f−1(y) , f−1({y})

For h ∈ H and b ∈ 2H, define

Bh , {c | h ∈ c} Bb ,⋂h∈b

Bh = {c | b ⊆ c}. (1.1)

Then Bh = B{h}. The sets Bh and ∼Bh are the subbasic open sets of the

Cantor space topology on 2H. The family of Borel sets B is the smallest σ-algebra containing the Cantor-open sets. Let Bb be the Boolean subalgebra of Bgenerated by {Bh | h ∈ b}.

Lemma 1.

(i) b ⊆ c⇔ Bc ⊆ Bb

(ii) Bb ∩Bc = Bb∪c

(iii) B∅ = 2H

∗Technical notes for the publication “Cantor Meets Scott: Foundations for ProbabilisticNetworks.” Steffen Smolka, Praveen Kumar, Nate Foster, Dexter Kozen, and Alexandra Silva.In POPL 2017, Paris.

1

Page 2: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

(iv) B2H =⋃b∈℘ω(H)) Bb.

If b is finite, so is Bb. The atoms of Bb are in one-to-one correspondence withthe subsets a ⊆ b, the subset a determining which Bh occur positively in theconstruction of the atom:

Aab ,⋂h∈a

Bh ∩⋂

h∈b−a

∼Bh = Ba −⋃

a⊂c⊆b

Bc = {c ∈ 2H | c ∩ b = a}, (1.2)

where ⊂ denotes proper subset. The sets Aab are the basic open sets of theCantor space. The notation Aab is reserved for such sets.

Lemma 2. For b finite and a ⊆ b, Ba =⋃a⊆c⊆bAcb.

Proof. By (1.2),⋃a⊆c⊆b

Acb =⋃

a⊆c⊆b

{d ∈ 2H | d ∩ b = c} = {d ∈ 2H | a ⊆ d} = Ba.

Lemma 3.

(i) Aab ⊆ Aa′b′ iff a′ ⊆ a and b′ − a′ ⊆ b− a.

(ii) Either Aab ⊆ Aa′b′ , Aa′b′ ⊆ Aab, or Aab ∩Aa′b′ = ∅.

Proof. (i) By (1.2), the assumption Aab ⊆ Aa′b′ reduces to

∀d d ∩ b = a ⇒ d ∩ b′ = a′ (1.3)

Taking d = a in (1.3), we have

a ∩ b = a⇒ a ∩ b′ = a′ ⇒ a′ ⊆ a.

Taking d = ∼(b− a) in (1.3), we have

∼(b− a) ∩ b = a⇒ ∼(b− a) ∩ b′ = a′

⇒ (b− a) ∩ b′ = b′ − a′

⇒ b′ − a′ ⊆ b− a.

Conversely, if a′ ⊆ a and b′ − a′ ⊆ b− a, then

b′ = (b′ − a′) ∪ a′ ⊆ (b− a) ∪ a = b

b′ ∩ (a− a′) = (b′ − a′) ∩ a ⊆ (b− a) ∩ a = ∅.

Thus if d ∩ b = a, then

d ∩ b′ = d ∩ b ∩ b′ = a ∩ b′ = (b′ ∩ (a− a′)) ∪ (b′ ∩ a′) = a′,

so (1.3) holds.

2

Page 3: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

(ii) Either Aab ⊆ Aa′b′ , Aa′b′ ⊆ Aab, or Aab ∩Aa′b′ = ∅.

Lemma 4 (see [3, Theorem III.13.A]). Any probability measure is uniquelydetermined by its values on Bb for b finite.

Proof. For b finite, the atoms of Bb are of the form (1.2). By the inclusion-exclusion principle,

µ(Aab) = µ(Ba −⋃

a⊂c⊆b

Bc) =∑a⊆c⊆b

(−1)|c−a|µ(Bc). (1.4)

Thus µ is uniquely determined on the atoms of Bb, therefore on all of Bb. AsB2H is the union of the Bb for b finite, µ is uniquely determined on B2H . Bythe monotone class theorem, the Borel sets B are the smallest monotone classcontaining B2H , and since µ(

⋃nAn) = supn µ(An) and µ(

⋂nAn) = infn µ(An),

µ is determined on all Borel sets.

Theorem 1. A function µ : {Bb | b finite} → [0, 1] extends to a measureµ : B → [0, 1] iff for all finite b and all a ⊆ b∑

a⊆c⊆b

(−1)|c−a|µ(Bc) ≥ 0

Moreover, the extension to B is unique.

Proof. The condition is clearly necessary by (1.4).

For sufficiency and uniqueness, we use the Caratheodory extension theorem.For each atom Aab of Bb, µ(Aab) is already determined uniquely by (1.4) andnonnegative by assumption. For each B ∈ Bb, write B uniquely as a union ofatoms and define µ(B) to be the sum of the µ(Aab) for all atoms Aab of Bbcontained in B.

We must show that µ(B) is well-defined. Note that the definition is given interms of b, and we must show that the definition is independent of the choiceof b. It suffices to show that the calculation using atoms of b′ = b ∪ {h}, h 6∈ b,gives the same result. Each atom of Bb is the disjoint union of two atoms of Bb′ :

Aab = Aa∪{h},b∪{h} ∪Aa,b∪{h}

and it suffices to show that the sum of their measures is the measure of Aab:

µ(Aa,b∪{h}) =∑

a⊆c⊆b∪{h}

(−1)|c−a|µ(Bc)

=∑a⊆c⊆b

(−1)|c−a|µ(Bc) +∑

a∪{h}⊆c⊆b∪{h}

(−1)|c−a|µ(Bc)

= µ(Aab)− µ(Aa∪{h},b∪{h}).

3

Page 4: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

To apply the Caratheodory extension theorem, we must show that µ iscountably additive, i.e. that µ(

⋃nAn) =

∑n µ(An) for any countable sequence

An ∈ B2H of pairwise disjoint sets whose union is in B2H .

For a finite sequences An ∈ B2H , write each An uniquely as a disjoint union ofatoms of Bb for some sufficiently large b such that all An ∈ Bb. Then

⋃nAn ∈ Bb,

the value of the atoms are given by (1.4), and the value of µ(⋃nAn) is well-

defined and equal to∑n µ(An).

We cannot have an infinite set of pairwise disjoint nonempty An ∈ B2H whoseunion is in B2H by compactness. All elements of B2H are clopen in the Cantortopology. If

⋃nAn = A ∈ B2H , then {An | n ≥ 0} would be an open cover of A

with no finite subcover.

2 DCPOs and the Scott Topology

We assume familiarity with basic domain theory; see [1] for an introduction.

A partial order (D,v) is a set D together with a reflexive, transitive, andantisymmetric relation v on D. For two elements x, y ∈ D we let x t y denotetheir v-least upper bound (i.e., their supremum), provided it exists. Analogously,the least upper bound of a subset C ⊆ D is denoted

⊔C, provided it exists. A

subset C ⊆ D is directed if for any two x, y ∈ C there exists some upper boundx, y v z ∈ C. A partial order (PO) is called a directed complete partial order(DCPO) if every directed subset C ⊆ D has a supremum

⊔C in D. If a PO has

a least element is is denoted by ⊥; if it has a greatest element it is denoted by >.

The set 2H forms a DCPO under the subset order ⊆ with suprema⊔C =

⋃C,

least element ⊥ = ∅, and greatest element > = H. The nonnegative real numberswith infinity R+ = {r ∈ R | r ≥ 0} ∪ {∞} form a DCPO under the naturalorder ≤ with suprema

⊔C = supC, least element ⊥ = 0, and greatest element

> =∞. The unit interval is a DCPO under the same order, but with > = 1.

Let D be a DCPO. A subset A ⊆ D is called up-closed (or an upper set) ifb ∈ A whenever a ∈ A and a v b. The smallest up-closed set containing A ⊆ Dis called its up-closure and is denoted A↑.

A subset A ⊆ D is (Scott-)open if it is up-closed and intersects every directedsubset B ⊆ D such that

⊔B ∈ A. The Scott-open sets form a topology on D

called the Scott topology.

A function f : D → E between DCPOs is (Scott-)continuous if it is continuouswith respect to the Scott topologies on D and E.

The Scott-open sets of R+ are the upper semi-infinite intervals (r,∞], r ∈ R+.The Scott-open sets of 2H are denoted O and are characterized in Lemma 6below.

An element a of a DCPO is called finite ([1] uses the term compact) if for anydirected set A, if a v

⊔A, then there exists b ∈ A such that a v b. Equivalently,

4

Page 5: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

a is finite if its up-closure {a}↑ is Scott-open.

A DCPO is called algebraic if for every element b, the finite elements v-belowb form a directed set and b is the supremum of this set. The DCPO 2H underthe subset order is algebraic, the finite elements of 2H being the finite subsets ofH, and {a}↑ = Ba.

A set in a topological space is compact-open if it is compact (every opencover has a finite subcover) and open.

Here we recall some general facts. These are all well-known, but we statethem as a lemma for future reference.

Lemma 5.

(i) The cartesian product of any collection of DCPOs is a DCPO under thecomponentwise order.

(ii) A function f : D → E between DCPOs is Scott-continuous iff the followingtwo properties hold:

• f is monotone, that is, if a v b, then f(a) v f(b);

• f preserves suprema of directed sets in the sense that f(⊔D) =⊔

a∈D f(a)

(see [1, Proposition 2.3.4]).

(iii) If E is a DCPO and D is any set, then the family of functions f : D → Eis a DCPO under the pointwise order f v g iff for all a ∈ D, f(a) v g(a).The supremum of a directed set D of functions D → E is the function(⊔D)(a) =

⊔f∈Df(a).

(iv) Let E be a DCPO and D1, D2 sets. There is a homeomorphism (bicontinu-ous bijection)

curry : (D1 ×D2 → E)→ (D1 → D2 → E)

between the DCPOs D1 ×D2 → E and D1 → D2 → E, where all functionspaces in question are ordered pointwise. The inverse of curry is denoteduncurry.

(v) If D,E are DCPOs, then the supremum of a directed set of continuousfunctions D → E is continuous. Thus the family of continuous functionsD → E form a DCPO. This space is denoted [D → E].

(vi) In an algebraic DCPO, the open sets {a}↑ for finite a form a base for theScott topology.

(vii) An element of an algebraic DCPO is compact-open iff it is a finite unionof basic open sets {a}↑.

5

Page 6: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Let O denote the family of Scott-open sets of 2H.

Lemma 6. A subset B ⊆ 2H is Scott-open iff there exists F ⊆ ℘ω(H) such thatB =

⋃a∈F Ba.

Proof. This follows from the observation that (2H,⊆) is an algebraic DCPOwhose finite elements are the finite sets ℘ω(H), and that their up-closures {a}↑,a ∈ ℘ω(H), form a base for the Scott topology (Lemma 5(vi)).

Here are some facts about the Scott topology on 2H.

• The Scott topology is weaker than the Cantor space topology. For example,∼Bh is Cantor-open but not Scott-open. However, the Borel sets of thetwo topologies are the same, as ∼Bh is a Π0

1 Borel set.1

• The open sets O ordered by the subset relation forms an ω-complete latticewith bottom element BH = {H} and top element B∅ = 2H.

• The sets Ba for a ∈ ℘ω(H) are a base for the Scott topology. The sets Bh

for h ∈ H are a subbase.

• The finite sets a ∈ ℘ω(H) are dense and countable, thus the space isseparable.

• Every open set is a countable union of basic open sets Ba, a ∈ ℘ω(H).

• Unlike the Cantor topology, the space is not Hausdorff, metrizable, orcompact. It is not Hausdorff, as any nonempty open set contains H.However, it is satisfies the weaker T0 separation property: For any pair ofpoints a, b with a 6⊆ b, a ∈ Ba but b 6∈ Ba.

• There is an up-closed Π02 Borel set with an uncountable set of minimal

elements (Lemma 33 below).

• There are up-closed Borel sets with no minimal elements; for example, thefamily of cofinite subsets of H. This is a Σ0

3 Borel set.

• The compact-open sets are those of the form F↑, where F is a finite set offinite sets. There are plenty of open sets that are not compact-open, e.g.B∅ − {∅} =

⋃h∈HBh .

Lemma 7. Let b ∈ 2H be finite and let F ⊆ 2b. Then⋃a∈F Aab ∈ O iff

F = F↑ ∩ 2b.

1References to the Borel hierarchy Σ0n and Π0

n refer to the Scott topology. Although theScott and Cantor topologies generate the same Borel sets, their Borel hierarchies are different.

6

Page 7: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Proof. Suppose F = F↑ ∩ 2b. By Lemma 2,⋃a∈F

Aab =⋃a∈F

⋃a⊆c⊆b

Acb =⋃a∈F

Ba ∈ O.

Conversely, suppose⋃a∈F Aab ∈ O. Then for any a ∈ F and a ⊆ c ⊆ b,

Acb ⊆ Bc ⊆ Ba ⊆⋃a∈F

Aab.

The first inclusion is by Lemma 2; the second is by the fact that a ⊆ c; and thethird is because a ∈ Aab,

⋃a∈F Aab is in O and therefore up-closed in 2H, and

Ba = {a}↑ is the smallest up-closed set containing a. Since the atoms of Bb arepairwise disjoint and Acb is nonempty (it contains c), it follows that c ∈ F .

3 Cantor Meets Scott

In this section we establish a strong correspondence between the Cantor andScott topologies on 2H.

Consider the infinite triangular matrix E and its inverse E−1 with rows andcolumns indexed by the finite subsets of H, where

Eac = [a ⊆ c] E−1ac = (−1)|c−a|[a ⊆ c].

These matrices are indeed inverses: For a, d ∈ ℘ω(H),

(E · E−1)ad =∑c

Eac · E−1cd =

∑c

[a ⊆ c] · [c ⊆ d] · (−1)|d−c|

=∑a⊆c⊆d

(−1)|d−c| = [a = d],

thus E · E−1 = I, and similarly E−1 · E = I.

Recall that the Cantor basic open sets are the elements Aab for b finite anda ⊆ b. Those for fixed finite b are the atoms of the Boolean algebra Bb. Theyform the basis of a 2|b|-dimensional linear space. The Scott basic open sets Bafor a ⊆ b are another basis for the same space. The two bases are related bythe matrix E[b], the 2b × 2b submatrix of E with rows and columns indexed bysubsets of b. One can show that the finite matrix E[b] is invertible with inverseE[b]−1 = (E−1)[b].

Lemma 8. Let µ be a measure on 2H and b ∈ ℘ω(H). Let X,Y be vectorsindexed by subsets of b such that Xa = µ(Ba) and Ya = µ(Aab) for a ⊆ b. LetE[b] be the 2b × 2b submatrix of E. Then X = E[b] · Y .

7

Page 8: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Proof. For any a ⊆ b,

Xa = µ(Ba) =∑a⊆c⊆b

µ(Acb)

=∑c

[a ⊆ c] · [c ⊆ b] · µ(Acb)

=∑c

E[b]ac · Yc = (E[b] · Y )a.

The matrix-vector equation X = E[b] · Y captures the fact that for a ⊆ b,Ba is the disjoint union of the atoms Acb of Bb for a ⊆ c ⊆ b, and consequentlyµ(Ba) is the sum of µ(Acb) for these atoms. The inverse equation X = E[b]−1 ·Ycaptures the inclusion-exclusion principle for Bb.

In fact, more can be said about the structure of E. For any b ∈ 2H, finiteor infinite, let E[b] be the submatrix of E with rows and columns indexed bythe subsets of b. If a ∩ b = ∅, then E[a ∪ b] = E[a] ⊗ E[b], where ⊗ denotesKronecker product. The formation of the Kronecker product requires a notion ofpairing on indices, which in our case is given by disjoint set union. For example,

E[{h1}] =

∅ {h1}

∅[

1 1]

{h1} 0 1E[{h2}] =

∅ {h2}

∅[

1 1]

{h2} 0 1

E[{h1, h2}] =

∅ {h1} {h2} {h1,h2}

1 1 1 1{h1} 0 1 0 1

{h2} 0 0 1 1{h1,h2} 0 0 0 1

= E[{h1}]⊗ E[{h2}].

As (E ⊗ F )−1 = E−1 ⊗ F−1 for Kronecker products of invertible matrices, wealso have

E[{h1}]−1 =

[1 −10 1

]E[{h2}]−1 =

[1 −10 1

]

E[{h1, h2}]−1 = E[{h1}]−1 ⊗ E[{h2}]−1 =

1 −1 −1 10 1 0 −10 0 1 −10 0 0 1

.The matrix E can be viewed as the infinite Kronecker product

⊗h∈HE[{h}].

Theorem 2. The probability measures on (2H,B) are in one-to-one correspon-dence with pairs of matrices M,N ∈ R℘ω(H)×℘ω(H) such that

8

Page 9: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

(i) M is diagonal with entries in [0, 1],

(ii) N is nonnegative, and

(iii) N = E−1ME.

The correspondence associates the probability measure µ with the matrices

Nab = µ(Aab) Mab = [a = b] · µ(Ba). (3.1)

Proof. Given a probability measure µ, certainly (i) and (ii) hold of the matricesM and N formed from µ by the rule (3.1). For (iii), we calculate:

(E−1ME)ab =∑c,d

E−1ac McdEdb

=∑c,d

[a ⊆ c] · (−1)|c−a| · [c = d] · µ(Mcd) · [d ⊆ b]

=∑a⊆c⊆b

(−1)|c−a| · µ(Bc) = µ(Aab) = Nab.

That the correspondence is one-to-one is immediate from Theorem 1.

4 A DCPO on Markov Kernels

For measures µ, ν on 2H, define µ v ν if µ(B) ≤ ν(B) for all B ∈ O. Equivalently,µ v ν iff the signed measure ν − µ takes only nonnegative values on O (it maytake negative values on Borel sets not in O). This order was first defined bySaheb-Djahromi [7].

Theorem 3. The probability measures on (2H,B) ordered by v form a DCPOwith bottom element δ∅ and top element δH .

S-D proof is more general, but very long (5 journal pages). Ours is considerablyshorter due to the extension theorem. –DCK

The relation v is a partial order. Reflexivity and transitivity are clear, andantisymmetry follows from Lemma 4.

Proof. To show that suprema of directed sets exist, let D be a directed set ofmeasures, and define

(⊔D)(B) , sup

µ∈Dµ(B), B ∈ O.

9

Page 10: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

This is clearly the supremum of D, provided it defines a valid measure.2 To showthis, choose a countable chain µ0 v µ1 v · · · in D such that µm v µn for allm < n and (

⊔D)(Bc)− µn(Bc) ≤ 1/n for all c such that |c| ≤ n. Then for all

finite c ∈ 2H, (⊔D)(Bc) = supn µn(Bc).

Then⊔D is a measure by Theorem 1 because for all finite b and a ⊆ b,∑a⊆c⊆b

(−1)|c−a|(⊔D)(Bc) =

∑a⊆c⊆b

(−1)|c−a| supnµn(Bc)

= limn

∑a⊆c⊆b

(−1)|c−a|µn(Bc)

≥ 0.

To show that δ∅ is v-minimum, observe that for all B ∈ O,

δ∅(B) = [∅ ∈ B] = [B = B∅ = 2H]

as B∅ = 2H is the only up-closed set containing ∅. Thus for all measures µ,δ∅(2H) = 1 = µ(2H), and for all B ∈ O, B 6= 2H, δ∅(B) = 0 ≤ µ(B).

Finally, to show that δH is v-maximum, observe that every nonempty B ∈ Ocontains H because it is up-closed. Therefore, δH is the constant function 1 onO − {∅}, making it v-maximum.

Lemma 9. µ v µ & ν and ν v µ & ν.

Proof. For any up-closed measurable set B,

µ(B) = µ(B) · ν(2H) = (µ× ν)(B × 2H)

= (µ× ν)({(b, c) | b ∈ B})≤ (µ× ν)({(b, c) | b ∪ c ∈ B}) = (µ & ν)(B).

and similarly for ν.

Surprisingly, despite Lemma 9, the probability measures do not form anupper semilattice under v, although counterexamples are difficult to construct.A counterexample is given in Appendix C.

Now we lift the order v to Markov kernels P : 2H × B → [0, 1]. The order isdefined pointwise on kernels regarded as functions 2H ×O → [0, 1]; that is,

P v Q 4⇔ ∀a ∈ 2H ∀B ∈ O P (a,B) ≤ Q(a,B).

There are several equivalent ways of viewing the lifted order v:

2This is actually quite subtle. One might be tempted to define

(⊔

D)(B) , supµ∈D

µ(B), B ∈ B

However, this definition would not give a valid probability measure in general. In particular, anincreasing chain of measures does not generally converge to its supremum pointwise. However,it does converge pointwise on O.

10

Page 11: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Lemma 10. The following are equivalent:

(i) P v Q, that is, for all a ∈ 2H and B ∈ O, P (a,B) ≤ Q(a,B);

(ii) for all a ∈ 2H, P (a,−) v Q(a,−) in the DCPO of measures M(2H);

(iii) for all B ∈ O, P (−, B) v Q(−, B) in the DCPO of functions 2H → [0, 1];

(iv) curryP v curryQ in the DCPO of functions 2H →M(2H).

Proof. To show that (i), (ii), and (iv) are equivalent,

∀a ∈ 2H ∀B ∈ O P (a,B) ≤ Q(a,B)

⇔ ∀a ∈ 2H (∀B ∈ O P (a,B) ≤ Q(a,B))

⇔ ∀a ∈ 2H P (a,−) v Q(a,−)

⇔ ∀a ∈ 2H (curryP )(a) v (curryQ)(a)

⇔ curryP v curryQ.

To show that (i) and (iii) are equivalent,

∀a ∈ 2H ∀B ∈ O P (a,B) ≤ Q(a,B)

⇔ ∀B ∈ O (∀a ∈ 2H P (a,B) ≤ Q(a,B))

⇔ ∀B ∈ O P (−, B) v Q(−, B).

ProbNetKAT programs will be interpreted as continuous kernels. A Markovkernel P : 2H×B → [0, 1] continuous if it is Scott-continuous in its first argument;that is, for any fixed A ∈ O, P (a,A) ≤ P (b, A) whenever a ⊆ b, and for anydirected set D ⊆ 2H, P (

⋃D,A) = supa∈D P (a,A). This is the same as saying

that its curried version curryP : 2H →M(2H) is Scott-continuous as a functionfrom the DCPO 2H ordered by ⊆ to the DCPO of probability measures orderedby v.

We will show in §4.3 that all ProbNetKAT programs give rise to continuouskernels.

Theorem 4. The continuous kernels P : 2H × B → [0, 1] ordered by v form acontinuous DCPO with basis consisting of kernels of the form b ; P ; d for P anarbitrary continuous kernel and b, d filters on finite sets b and d; that is, kernelsthat drop all input packets except for those in b and all output packets exceptthose in d.

Proof. We must show that the supremum of any directed set of continuousMarkov kernels is a continuous Markov kernel. In general, the supremumof a directed set of continuous functions between DCPOs is continuous, asnoted in Lemma 5(v). Given a directed set D of continuous kernels, we apply

11

Page 12: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

this to the directed set {curryP : 2H → M(2H) | P ∈ D} to derive that⊔P∈D curryP is continuous, then use the fact that curry is continuous to infer

that⊔P∈D curryP = curry

⊔D, therefore curry

⊔D is continuous. This says that

the function P : 2H × B → [0, 1] is continuous in its first argument.

We must still argue that the supremum⊔D is a Markov kernel, that is,

a measurable function in its first argument and a probability measure in itssecond argument. The first statement follows from the fact that any continuousfunction is measurable with respect to the Borel sets generated by the topologiesof the two spaces. For the second statement, we appeal to Theorem 3 and thecontinuity of curry:

(curry⊔D)(a) = (

⊔P∈D curryP )(a) =

⊔P∈D(curryP )(a),

which is a supremum of a directed set of probability measures, therefore byTheorem 3 is itself a probability measure.

To show that it is a continuous DCPO with basis of the indicated form, wenote that for any a ∈ 2H and B ∈ O,

(b ; P ; d)(a,B) = P (a ∩ b, {c | c ∩ d ∈ B}). (4.1)

Every element of the space is the supremum of a directed set of such elements.Given a continuous kernel P , consider the directed set D of all elements b ; P ; dfor b, d finite. Then for any a ∈ 2H and B ∈ O,

(⊔D)(a,B) = sup

b,d∈℘ω(H)

P (a ∩ b, {c | c ∩ d ∈ B}) (4.2)

= supd∈℘ω(H)

P (a, {c | c ∩ d ∈ B}) (4.3)

= P (a,B), (4.4)

the inference (4.2) from (4.1), the inference (4.3) from the fact that P is con-tinuous in its first argument, and the inference (4.3) from the fact that the sets{c | c∩ d ∈ B} for d ∈ ℘ω(H) form a directed set of Scott-open sets whose unionis B and that P is a measure in its second argument.

It is not true that the space of continuous kernels is algebraic with finiteelements b ; P ; d. A counterexample is given in Appendix E.

4.1 Products and Integration

As pointed out by Jones [4, §3.6], the product σ-algebra of the Borel sets oftwo topological spaces X,Y is in general not the same as the Borel sets of thetopological product X × Y , although this property does hold for the Cantorspace, as its basic open sets are clopen. More importantly, as also observed in[4, §3.6], the Scott topology on the product of DCPOs with the componentwiseorder is not necessarily the same as the product topology. However, in our case,the two topologies coincide.

12

Page 13: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Theorem 5. Let Dα, α < κ, be a collection of algebraic DCPOs with Fα thefinite elements of Dα. Then the product

∏α<κDα with the componentwise order

is an algebraic DCPO with finite elements

F = {c ∈∏α Fα | πα(c) = ⊥ for all but finitely many α}.

Proof. The projections πβ :∏αDα → Dβ are easily shown to be continuous with

respect to the componentwise order. For any d ∈∏α<κDα, the set {d}↓ ∩ F is

directed, and d =⊔

({d}↓∩F ): for any α, the set πα({d}↓∩F ) = {πα(d)}↓∩Fαis directed, thus

πα(d) =⊔

({πα(d)}↓ ∩ Fα) =⊔

(πα({d}↓ ∩ F )) = πα(⊔

({d}↓ ∩ F )),

and as α was arbitrary, d =⊔

({d}↓ ∩ F ).

It remains to show that {c}↑ =∏α<κ{πα(c)}↑ is open for c ∈ F . Let A be a

directed set with⊔A ∈ {c}↑. For each α, {πα(a) | a ∈ A} is directed, and⊔

a∈Aπα(a) = πα(

⊔A) ∈ πα({c}↑) = {πα(c)}↑,

so there exists aα ∈ A such that πα(aα) ∈ {πα(c)}↑. Since A is directed, thereis a single a ∈ A that majorizes the finitely many aα such that πα(c) 6= ⊥. Thenπα(a) ∈ {πα(c)}↑ for all α, thus a ∈ {c}↑.

Corollary 1. The Scott topology on a product of algebraic DCPOs with respectto the componentwise order coincides with the product topology induced by theScott topology on each component.

Proof. Let∏α<κDα be a product of algebraic DCPOs with O0 the product

topology and O1 the Scott topology. As noted in the proof of Theorem 5,the projections πβ :

∏αDα → Dβ are continuous with respect to O1. By

definition, O0 is the weakest topology on the product such that the projectionsare continuous, so O0 ⊆ O1.

For the reverse inclusion, we use the observation that the sets {c}↑ for finiteelements c ∈ F as defined in Theorem 5 form a base for the topology O1. Thesesets are also open in O0, since they are finite intersections of sets of the formπ−1α ({πα(c)}↑), and {πα(c)}↑ is open in Dα since πα(c) ∈ Fα. As O1 is the

smallest topology containing its basic open sets, O1 ⊆ O0.

A function g : 2H → R+ is O-simple if it is a finite linear combination ofthe form

∑A∈F rA1A, where F is a finite subset of O. Let S denote the set of

O-simple functions.

Theorem 6. Let f be a bounded Scott-continuous function f : 2H → R+. Then

supg∈Sg≤f

∫g dµ =

∫f dµ = inf

g∈Sf≤g

∫g dµ

under Lebesgue integration.

13

Page 14: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Proof. Let ε > 0 and rN = supa∈2H f(a). Let

0 = r0 < r1 < · · · < rN

such that ri+1 − ri < ε, 0 ≤ i ≤ N − 1, and set

Ai = {a | f(a) > ri} = f−1((ri,∞)) ∈ O, 0 ≤ i ≤ N.

Then Ai+1 ⊆ Ai and

Ai −Ai+1 = {a | ri < f(a) ≤ ri+1} = f−1((ri, ri+1]).

Let

f• =

N−1∑i=0

ri1Ai−Ai+1f• =

N−1∑i=0

ri+11Ai−Ai+1.

For a ∈ Ai −Ai+1,

f•(a) =

N−1∑i=0

ri1Ai−Ai+1(a) = ri < f(a)

≤ ri+1 =

N−1∑i=0

ri+11Ai−Ai+1(a) = f•(a),

and as a was arbitrary, f• ≤ f ≤ f• pointwise. Thus∫f• dµ ≤

∫f dµ ≤

∫f• dµ.

Moreover,∫f• dµ−

∫f• dµ =

N−1∑i=0

ri+1µ(Ai −Ai+1)−N−1∑i=0

riµ(Ai −Ai+1)

=N−1∑i=0

(ri+1 − ri)µ(Ai −Ai+1)

< ε ·N−1∑i=0

µ(Ai −Ai+1) = ε · µ(2H) = ε,

so the integral is approximated arbitrarily closely from above and below by thef• and f•. Finally, we argue that f• and f• are O-simple. Using the fact that

14

Page 15: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

r0 = 0 and AN = ∅ to reindex,

f• =

N−1∑i=0

ri1Ai−Ai+1 =

N−1∑i=0

ri1Ai −N−1∑i=0

ri1Ai+1

=

N−1∑i=0

ri+11Ai+1 −N−1∑i=0

ri1Ai+1 =

N−1∑i=0

(ri+1 − ri)1Ai+1 ,

f• =

N−1∑i=0

ri+11Ai−Ai+1 =

N−1∑i=0

ri+11Ai −N−1∑i=0

ri+11Ai+1

=

N−1∑i=0

ri+11Ai −N−1∑i=0

ri1Ai =

N−1∑i=0

(ri+1 − ri)1Ai ,

and both functions are O-simple since all Ai are in O.

Lemma 11.

(i) For any Scott-continuous function f : 2H → R+, the map

µ 7→∫f dµ (4.5)

is Scott-continuous with respect to the order v on M(2H).

(ii) For any probability measure µ, the map

f 7→∫f dµ (4.6)

is Scott-continuous with respect to the order v on [2H → [0, 1]].

Thus the Lebesgue integral is Scott-continuous in both arguments.

Proof. (i) We prove the result first for O-simple functions. If µ v ν, then forany O-simple function g =

∑A rA1A,∫

g dµ =

∫ ∑A

rA1A dµ =∑A

rAµ(A)

≤∑A

rAν(A) =

∫ ∑A

rA1A dν =

∫g dν.

Thus the map (4.5) is monotone. If D is a directed set of measures with respectto v, then∫

g d(⊔D) =

∫ ∑A

rA1A d(⊔D) =

∑A

rA(⊔D)(A)

= supµ∈D

∑A

rAµ(A) = supµ∈D

∫ ∑A

rA1A dµ = supµ∈D

∫g dµ.

15

Page 16: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Now consider an arbitrary Scott-continuous function f : 2H → R+. Let S isthe family of O-simple functions. By Theorem 6, if µ v ν, we have∫

f dµ = supg∈Sg≤f

∫g dµ ≤ sup

g∈Sg≤f

∫g dν =

∫f dν,

and if D is a directed set of measures with respect to v, then∫f d(

⊔D) = sup

g∈Sg≤f

∫g d(

⊔D) = sup

g∈Sg≤f

supµ∈D

∫g dµ

= supµ∈D

supg∈Sg≤f

∫g dµ = sup

µ∈D

∫f dµ.

(ii) The result is a straightforward consequence of Theorem 6.

Actually, this is just the monotone convergence theorem for Lebesgue Integration.In fact, it holds more generally for f : 2H → [0,∞], i.e. functions that may takeon infinite value. –Steffen

4.2 Continuous Operations on Measures

Lemma 12. For any probability measure µ on an algebraic DCPO and openset B, the value µ(B) is approximated arbitrarily closely from below by µ(C) forcompact-open sets C.

Proof. Since the sets {a}↑ for finite a form a base for the topology, and everycompact-open set is a finite union of such sets, the set K(B) of compact-opensubsets of B is a directed set whose union is B. Then

µ(B) = µ(⋃K(B)) = sup{µ(C) | C ∈ K(B)}.

Lemma 13. The product operator on measures in algebraic DCPOs is Scott-continuous in each argument.

Proof. The difficult part of the argument is monotonicity. Once we have that,then for any B,C ∈ O, we have (µ × ν)(B × C) = µ(B) · ν(C). Thus for anydirected set D of measures,

(⊔D × ν)(B × C) = (

⊔D)(B) · ν(C) = (sup

µ∈Dµ(B)) · ν(C)

= supµ∈D

(µ(B) · ν(C)) = supµ∈D

((µ× ν)(B × C))

= (⊔µ∈D(µ× ν))(B × C).

16

Page 17: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

By Theorem 5, the sets B × C for B,C ∈ O form a basis for the Scott topologyon the product space 2H × 2H, thus

⊔D × ν =

⊔µ∈D(µ× ν).

To show monotonicity, we use approximability by compact-open sets (Lemma12). We wish to show that if µ1 v µ2, then µ1 × ν v µ2 × ν. By Lemma 12, itsuffices to show that

(µ1 × ν)(⋃n

Bn × Cn) ≤ (µ2 × ν)(⋃n

Bn × Cn),

where the index n ranges over a finite set, and Bn and Cn are open sets of thecomponent spaces. Consider the collection of all atoms A of the Boolean algebragenerated by the Cn. For each such atom A, let

N(A) = {n | Cn occurs positively in A}.

Then ⋃n

Bn × Cn =⋃A

(⋃

n∈N(A)

Bn)×A.

The right-hand side is a disjoint union, since the A are pairwise disjoint. Then

(µ1 × ν)(⋃n

Bn × Cn) = (µ1 × ν)(⋃A

(⋃

n∈N(A)

Bn)×A)

=∑A

(µ1 × ν)((⋃

n∈N(A)

Bn)×A)

=∑A

µ1(⋃

n∈N(A)

Bn) · ν(A)

≤∑A

µ2(⋃

n∈N(A)

Bn) · ν(A)

= (µ2 × ν)(⋃n

Bn × Cn).

Let S and T be measurable spaces and f : S → T a measurable function. Fora measure µ on S, the push-forward measure f∗(µ) is the measure µ ◦ f−1 on T .

Lemma 14. If f : (2H)κ → 2H is Scott-continuous with respect to the subset or-der, then the push-forward operator f∗ :M((2H)κ)→M(2H) is Scott-continuouswith respect to v.

Proof. Let µ, ν ∈ M((2H)κ), µ v ν. If B ∈ O, then f−1(B) is Scott-open in(2H)κ, so f∗(µ)(B) = µ(f−1(B)) ≤ ν(f−1(B)) = f∗(ν)(B). As B ∈ O was

17

Page 18: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

arbitrary, f∗(µ) v f∗(ν). Similarly, if D is any v-directed set inM((2H)κ), thenso is {f∗(µ) | µ ∈ D}, and

f∗(⊔D)(B) = (

⊔D)(f−1(B)) = sup

µ∈Dµ(f−1(B))

= supµ∈D

f∗(µ)(B) = (⊔µ∈Df∗(µ))(B)

for any B ∈ O, thus f∗(⊔D) =

⊔µ∈Df∗(µ).

Lemma 15. Parallel composition of measures (&) is Scott-continuous in eachargument.

Proof. By definition, µ & ν = (µ× ν) ;⋃−1

, where⋃

: 2H × 2H → 2H is the setunion operator. The set union operator is easily shown to be continuous withrespect to the Scott topologies on 2H × 2H and the 2H. By Lemma 14, the push-forward operator with respect to union is Scott-continuous with respect to v.By Lemma 13, the product operator is Scott-continuous in each argument withrespect to v. The operator & is the composition of these two Scott continuousoperators, therefore is itself Scott-continuous.

4.3 Continuous Kernels

In this section we prove that all ProbNetKAT programs give rise to continuouskernels.

Lemma 16. The deterministic kernel associated with any Scott-continuousfunction f : D → E is a continuous kernel.

Proof. Recall from [2] that deterministic kernels are those whose output measuresare Dirac measures (point masses). Any measurable function f : D → E uniquelydetermines a deterministic kernel Pf such that Pf (a,−) = δf(a) and vice versa

(this was shown in [2] for D = E = 2H). We show that if in addition f isScott-continuous, then the kernel Pf is continuous.

Let f : D → E be Scott-continuous. For any open B, if a v b, thenf(a) v f(b) since f is monotone. Since B is up-closed, if f(a) ∈ B, thenf(b) ∈ B. Thus

Pf (a,B) = [f(a) ∈ B] ≤ [f(b) ∈ B] = Pf (b, B).

If A ⊆ D is a directed set, then f(⊔A) =

⊔a∈A f(a). Since B is open,⊔

a∈A f(a) ∈ B iff there exists a ∈ A such that f(a) ∈ B. Then

Pf (⊔A,B) = [f(

⊔A) ∈ B] = [

⊔a∈Af(a) ∈ B]

= supa∈A

[f(a) ∈ B] = supa∈A

Pf (a,B).

18

Page 19: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

All atomic ProbNetKAT programs are deterministic and Scott-continuous.The assignment x := n takes a set a and returns (the Dirac measure on) theset {π[n/x] :h | π :h ∈ a}. The test x = n takes a set a and returns the set{π :h ∈ a | π(x) = n}. The generalized test b takes a set a and returns the seta∩ b. The dup operator takes a set a and returns the set {π :π :h | π :h ∈ a}. Allthese functions are of the form a 7→ {f(h) | h ∈ a}, where f is a partial functionH ⇀ H, and anything of this form is Scott-continuous:

• If a ⊆ b, then {f(h) | h ∈ a} ⊆ {f(h) | h ∈ b}; and

• If D ⊆ 2H is a directed set, then {f(h) | h ∈⋃D} =

⋃a∈D{f(h) | h ∈ a}.

Lemma 17. Let P be a continuous Markov kernel and f : 2H → R+ a Scott-continuous function. Then the map

a 7→∫c∈2H

f(c) · P (a, dc) (4.7)

is Scott-continuous.

Proof. The map (4.7) is the composition of the maps

a 7→ P (a,−) P (a,−) 7→∫c∈2H

P (a, dc) · f(c),

which are Scott-continuous by Lemmas 25 and 11, respectively, and the compo-sition of Scott-continuous maps is Scott-continuous.

Lemma 18. Product preserves continuity of Markov kernels: If P and Q arecontinuous, then so is P ×Q.

Proof. We wish to show that if a ⊆ b, then (P ×Q)(a,−) v (P ×Q)(b,−), andif A is a directed subset of 2H, then (P ×Q)(

⋃A) = supa∈A(P ×Q)(a,−). For

the first statement, using Lemma 13 twice,

(P ×Q)(a,−) = P (a,−)×Q(a,−) v P (b,−)×Q(a,−)

v P (b,−)×Q(b,−) = (P ×Q)(b,−).

For the second statement, for A a directed subset of 2H,

(P ×Q)(⊔A,−) = P (

⊔A,−)×Q(

⊔A,−)

= (⊔a∈AP (a,−))× (

⊔b∈AQ(b,−))

=⊔a∈A

⊔b∈AP (a,−)×Q(b,−)

=⊔a∈AP (a,−)×Q(a,−)

=⊔a∈A(P ×Q)(a,−).

19

Page 20: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Lemma 19. Sequential composition preserves continuity of Markov kernels: IfP and Q are continuous, then so is P ; Q.

Proof. We have

(P ; Q)(a,A) =

∫c∈2H

P (a, dc) ·Q(c, A).

Since Q is a continuous kernel, it is Scott-continuous in its first argument, thusso is P ; Q by Lemma 17.

Lemma 20. Parallel composition preserves continuity of Markov kernels: If Pand Q are continuous, then so is P & Q.

Proof. Suppose P and Q are continuous. By definition, P & Q = (P ×Q) ;⋃

.By Lemma 18, P ×Q is continuous, and

⋃: 2H × 2H → 2H is continuous. Thus

their composition is continuous by Lemma 19.

Need to generalize lem:seqcomp-preserves –DCK

Lemma 21. The probabilistic choice operator (⊕r) preserves continuity ofkernels.

Proof. If P and Q are continuous, then P ⊕r Q = rP + (1− r)Q. If a ⊆ b, then

(P ⊕r Q)(a,−) = rP (a,−) + (1− r)Q(a,−)

≤ rP (b,−) + (1− r)Q(b,−) = (P ⊕r Q)(b,−).

If A ⊆ 2H is a directed set, then

(P ⊕r Q)(⋃A,−) = rP (

⋃A,−) + (1− r)Q(

⋃A,−)

=⊔a∈A(rP (a,−) + (1− r)Q(a,−))

=⊔a∈A(P ⊕r Q)(a,−).

Lemma 22. The iteration operator (*) preserves continuity of kernels.

Proof. Suppose P is continuous. It follows inductively using Lemmas 20 and19 that P (n) is continuous. Since P ∗ =

⊔n P

(n) and since the supremumof a directed set of continuous kernels is continuous by Theorem 4, P ∗ iscontinuous.

Theorem 7. All ProbNetKAT programs give continuous Markov kernels.

Proof. By Lemmas 16, 20, 19, 21, and 22, all primitive programs are continuouskernels, and continuity is preserved by all the program operators.

20

Page 21: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

4.4 Continuous Operations on Kernels

In this section we show that all program operators are continuous functions onthe DCPO of continuous Markov kernels.

Lemma 23. The product operation on kernels (×) is Scott-continuous in eachargument.

Proof. We use Lemma 13. If P1 v P2, then for all a ∈ 2H,

(P1 ×Q)(a,−) = P1(a,−)×Q(a,−) v P2(a,−)×Q(a,−) = (P2 ×Q)(a,−).

Since a was arbitrary, P1 ×Q v P2 ×Q. For a directed set D of kernels,

(⊔D ×Q)(a,−) = (

⊔D)(a,−)×Q(a,−)

=⊔P∈DP (a,−)×Q(a,−)

=⊔P∈D(P (a,−)×Q(a,−))

=⊔P∈D(P ×Q)(a,−)

= (⊔P∈D(P ×Q))(a,−).

Since a was arbitrary,⊔D ×Q =

⊔P∈D(P ×Q).

Lemma 24. Parallel composition of kernels (&) is Scott-continuous in eachargument.

Proof. By definition, P & Q = (P ×Q) ;⋃

. By Lemmas 23 and 26, the productoperation and sequential composition are continuous in both arguments, thustheir composition is.

Lemma 25. Let P be a continuous Markov kernel. The map curryP is Scott-continuous with respect to the subset order on 2H and the order v on M(2H).

Proof. We have (curryP )(a) = P (a,−). Since P is monotone in its first argument,if a ⊆ b and B ∈ O, then P (a,B) ≤ P (b, B). As B ∈ O was arbitrary,

(curryP )(a) = P (a,−) v P (b,−) = (curryP )(b).

This shows that curryP is monotone.

Let D ⊆ 2H be a directed set. By the monotonicity of curryP , so is the set{(curryP )(a) | a ∈ D}. Then for any B ∈ O,

(curryP )(⋃D)(B) = P (

⋃D,B) = sup

a∈DP (a,B)

= supa∈D

(curryP )(a)(B) = (⊔a∈D(curryP )(a))(B),

thus (curryP )(⋃D) =

⊔a∈D(curryP )(a).

21

Page 22: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Lemma 26. Sequential composition of kernels (;) is Scott-continuous in eachargument.

Proof. To show that ; is continuous in its first argument, we wish to show thatif P1, P2, Q are any continuous kernels with P1 v P2, and if D is any directedset of continuous kernels, then

P1 ; Q ≤ P2 ; Q (⊔D) ; Q =

⊔P∈D(P ; Q).

We must show that for all a ∈ 2H and BO,∫c

P1(a, dc) ·Q(c,B) ≤∫c

P2(a, dc) ·Q(c,B)∫c

(⊔D)(a, dc) ·Q(c,B) = sup

P∈D

∫c

P (a, dc) ·Q(c,B).

By Lemma 10, for all a ∈ 2H, P1(a,−) v P2(a,−) and (⊔D)(a,−) =

⊔P∈DP (a,−),

and Q(−, B) is a Scott-continuous function by assumption. The result followsfrom Lemma 11(i).

The argument that ; is continuous in its second argument is similar, usingLemma 11(ii). We wish to show that if P,Q1, Q2 are any continuous kernelswith Q1 v Q2, and if D is any directed set of continuous kernels, then

P ; Q1 ≤ P ; Q2 P ;⊔D =

⊔Q∈D(P ; Q).

We must show that for all a ∈ 2H and B ∈ O,∫c

P (a, dc) ·Q1(c,B) ≤∫c

P (a, dc) ·Q2(c,B)∫c

P (a, dc) · (⊔D)(c,B) = sup

Q∈D

∫c

P (a, dc) ·Q(c,B).

By Lemma 10, for all B ∈ O, Q1(−, B) v Q2(−, B) and (⊔D)(−, B) =⊔

Q∈DQ(−, B). The result follows from Lemma 11(ii).

Lemma 27. The probabilistic choice operator applied to kernels (⊕r) is contin-uous in each argument.

Proof. If P and Q are continuous, then P ⊕r Q = rP + (1− r)Q. If P1 v P2,then for any a ∈ 2H and B ∈ O,

(P1 ⊕r Q)(a,B) = rP1(a,B) + (1− r)Q(a,B)

≤ rP2(a,B) + (1− r)Q(a,B)

= (P2 ⊕r Q)(a,B),

22

Page 23: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

so P1 ⊕r Q v P2 ⊕r Q. If D is a directed set of kernels and BO, then

(⊔D ⊕r Q)(a,B) = r(

⊔D)(a,B) + (1− r)Q(a,B)

= supP∈D

(rP (a,B) + (1− r)Q(a,B))

= supP∈D

(P ⊕r Q)(a,B).

Lemma 28. The iteration operator applied to kernels (*) is continuous.

Proof. It is a straightforward consequence of Lemma 30 and Theorem 10 thatif P v Q, then P ∗ v Q∗. Now let D be a directed set of kernels. It follows byinduction using Lemmas 24 and 26 that the operator P 7→ P (n) is continuous,thus

(⊔D)∗ =

⊔n(⊔D)(n) =

⊔n

⊔P∈DP

(n) =⊔P∈D

⊔nP

(n) =⊔P∈DP

∗.

5 Relation to the Semantics of [2]

In this section the notation P ∗ refers to the star operator in the semantics of [2].We need a different notation. –DCK

The following results are needed to connect the semantics of iteration pre-sented in [2] with the least fixpoint semantics presented here. Recall from [2]the approximants

P (0) = skip P (m+1) = skip & P ; P (m).

It was shown in [2] that for any c ∈ 2H, the measures P (m)(c,−) converge weaklyto P ∗(c,−); that is, for any bounded (Cantor-)continuous real-valued function fon 2H, the expected values of f with respect to the measures P (m)(c,−) convergeto the expected value of f with respect to P ∗(c,−):

limm→∞

∫a∈2H

f(a) · P (m)(c, da) =

∫a∈2H

f(a) · P ∗(c, da).

Steffen’s short proof –DCK

Theorem 8. The kernel Q =⊔n∈N P

(n) is the unique fixpoint of (λQ. skip &

P ; Q) such that P (n)(a) weakly converges to Q(a) (with respect to the Cantortopology) for all a ∈ 2H.

23

Page 24: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Proof. Let P ∗ denote any fixpoint of (λQ. skip & P ; Q) such that the measureµn = P (n)(a) weakly converges to the measure µ = P ∗(a), i.e. such that for all(Cantor-)continuous bounded functions f : 2H → R

limn→∞

∫fdµn =

∫fdµ

for all a ∈ 2H. Let ν = Q(a). Fix an arbitrary Scott-open set V . Since 2H isa Polish space under the Cantor topology, there exists an increasing chain ofcompact sets

C1 ⊆ C2 ⊆ · · · ⊆ V such that supn∈N

µ(Cn) = µ(V ).

By Urysohn’s lemma (see [5, 6]), there exist continuous functions fn : 2H → [0, 1]such that fn(x) = 1 for x ∈ Cn and f(x) = 0 for x ∈ ∼V . We thus have

µ(Cn) =

∫1Cn

≤∫fndµ by monotonicity of

∫= limm→∞

∫fndµm by weak convergence

≤ limm→∞

∫1V dµm by monotonicity of

∫= limm→∞

µm(V )

= ν(V ) by pointwise convergence on O

Taking the supremum over n, we get that µ(V ) ≤ ν(V ). Since ν is the v-leastfixpoint, the measures must therefore agree on V , which implies that they areequal by Theorem 1. Thus, any fixpoint of (λQ. skip & P ; Q) with theweak convergence property must be equal to Q. But the fixpoint P ∗ defined inprevious work does enjoy the weak convergence property, and therefore so doesQ = P ∗.

Dexter’s longer proof –DCK

Lemma 29. In a Polish space D, the values of∫a∈D

f(a) · µ(da)

for continuous f : D → [0, 1] determine µ uniquely.

Proof. Let A be a Borel set. Since we are in a Polish space, µ(A) is approximatedarbitrarily closely from below by µ(C) for compact sets C ⊆ A and from above

24

Page 25: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

by µ(U) for open sets U ⊇ A. By Urysohn’s lemma (see [5, 6]), there exists acontinuous function f : D → [0, 1] such that f(a) = 1 for all a ∈ C and f(a) = 0for all a 6∈ U . We thus have

µ(C) =

∫a∈C

f(a) · µ(da) ≤∫a∈D

f(a) · µ(da) =

∫a∈U

f(a) · µ(da) ≤ µ(U)

µ(C) ≤ µ(A) ≤ µ(U),

thus ∣∣∣∣µ(A)−∫a∈D

f(a) · µ(da)

∣∣∣∣ ≤ µ(U)− µ(C),

and the right-hand side can be made arbitrarily small.

By Lemma 29, if P,Q are two Markov kernels and∫a∈2H

f(a) · P (c, da) =

∫a∈2H

f(a) ·Q(c, da)

for all Cantor-continuous f : 2H → [0, 1], then P (c,−) = Q(c,−). If this holdsfor all c ∈ 2H, then P = Q.

Theorem 9. Let A be a directed set of probability measures with respect to vand let f : 2H → [0, 1] be a Cantor-continuous function. Then

limµ∈A

∫c∈2H

f(c) · dµ =

∫c∈2H

f(c) · d(⊔A).

Proof. Let ε > 0. Since all continuous functions on a compact space are uniformlycontinuous, for sufficiently large finite b and for all a ⊆ b, the value of f does notvary by more than ε on Aab; that is, supc∈Aab

f(c)− infc∈Aabf(c) < ε. Then for

any µ, ∫c∈Aab

f(c) · µ(dc)−∫c∈Aab

infc∈Aab

f(c) · µ(dc)

≤∫c∈Aab

( supc∈Aab

f(c)− infc∈Aab

f(c)) · µ(dc) < ε · µ(Aab).

Moreover,

(⊔A)(Aab) =

∑a⊆c⊆b

(−1)|c−a|(⊔A)(Bc) =

∑a⊆c⊆b

(−1)|c−a| supµ∈A

µ(Bc)

= limµ∈A

∑a⊆c⊆b

(−1)|c−a|µ(Bc) = limµ∈A

µ(Aab),

25

Page 26: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

so for sufficiently large µ ∈ A, µ(Aab) does not differ from (⊔A)(Aab) by more

than ε · 2−|b|. Then for any constant r ∈ [0, 1],∣∣∣∣∫c∈Aab

r · (⊔A)(dc)−

∫c∈Aab

r · µ(dc)

∣∣∣∣ = r · |(⊔A)(Aab)− µ(Aab)|

≤ |(⊔A)(Aab)− µ(Aab)| < ε · 2−|b|.

Combining these observations,∣∣∣∣∫c∈2H

f(c) · (⊔A)(dc)−

∫c∈2H

f(c) · µ(dc)

∣∣∣∣=

∣∣∣∣∣∣∑a⊆b

∫c∈Aab

f(c) · (⊔A)(dc)−

∑a⊆b

∫c∈Aab

f(c) · µ(dc)

∣∣∣∣∣∣≤∑a⊆b

(∣∣∣∣∫c∈Aab

f(c) · (⊔A)(dc)−

∫c∈Aab

infc∈Aab

f(c) · (⊔A)(dc)

∣∣∣∣+

∣∣∣∣∫c∈Aab

infc∈Aab

f(c) · (⊔A)(dc)−

∫c∈Aab

infc∈Aab

f(c) · µ(dc)

∣∣∣∣+

∣∣∣∣∫c∈Aab

infc∈Aab

f(c) · µ(dc)−∫c∈Aab

f(c) · µ(dc)

∣∣∣∣)≤∑a⊆b

(ε · (⊔A)(Aab) + ε · 2−|b| + ε · µ(Aab)

)= 3ε.

As ε > 0 was arbitrary,

limµ∈A

∫c∈2H

f(c) · µ(dc) =

∫c∈2H

f(c) · (⊔A)(dc).

Lemma 30. If P v Q then P (n) v Q(n).

Proof. By induction on n ∈ N. The claim is trivial for n = 0. For n > 0, weassume that P (n−1) v Q(n−1) and deduce

P (n) = skip & P ; P (n−1) v skip & Q ; Q(n−1) = Q(n)

by monotonicity of sequential and parallel composition (Lemmas 26 and 24,respectively).

Lemma 31. If m ≤ n then P (m) v P (n).

Proof. We have P (0) v P (1) by Lemmas 9 and 10. Proceeding by inductionusing Lemma 30, we have P (n) v P (n+1) for all n. The result follows fromtransitivity.

26

Page 27: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Let P ∗ be the iterate of P as defined in [2]. As proved in that paper, P ∗

satisfies the fixpoint equation

P ∗ = skip & P ; P ∗.

Theorem 10. P ∗ =⊔n P

(n).

Proof. Consider the continuous transformation

TP (Q) , skip & P ; Q

on the DCPO of continuous Markov kernels. The continuity of TP follows fromLemmas 24 and 26. The bottom element ⊥ is drop in this space, and

TP (⊥) = skip = P (0) TP (P (n)) = skip & P ; P (n) = P (n+1),

thus Tn+1P (⊥) = P (n), so

⊔TnP (⊥) =

⊔n P

(n), and this is the least fixpoint ofTP . As shown in [2], P ∗ is also a fixpoint of TP , so it remains to show thatP ∗ =

⊔n P

(n).

Let c ∈ 2H. As shown in [2], the measures P (n)(c,−) converge weakly toP ∗(c,−); that is, for any Cantor-continuous function f : 2H → [0, 1], the expectedvalues of f relative to P (n) converge to the expected value of f relative to P ∗:

limn

∫f(a) · P (n)(c, da) =

∫f(a) · P ∗(c, da).

But by Theorem 9, we also have

limn

∫f(a) · P (n)(c, da) =

∫f(a) · (

⊔n

P (n))(c, da),

thus ∫f(a) · P ∗(c, da) =

∫f(a) · (

⊔nP

(n))(c, da).

As f was arbitrary, we have P ∗(c,−) = (⊔nP

(n))(c,−) by Lemma 29, and as cwas arbitrary, we have P ∗ =

⊔nP

(n).

6 Approximation

For a program p, define the n-th approximant 〈p〉n inductively as

〈p〉n , p (for p primitive)

〈q ⊕r r〉n , 〈q〉n ⊕r 〈r〉n〈q & r〉n , 〈q〉n & 〈r〉n〈q ; r〉n , 〈q〉n ; 〈r〉n〈q∗〉n , q(n)

27

Page 28: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Intuitively, 〈p〉n is just p where indefinite iteration −∗ is replaced by boundediteration −(n).

Theorem 11. The approximants of a program p form a v-increasing chain withsupremum p, that is 〈p〉1 v 〈p〉2 v . . . and

⊔n≥0J〈p〉nK = JpK.

Proof. By structural induction on p.

This means that any program can be approximated using only finite distri-butions!

References

[1] Samson Abramsky and Achim Jung. Domain theory. In S. Abramsky, Dov M.Gabbay, and T.S.E. Maibaum, editors, Handbook of Logic in ComputerScience, volume 3, pages 1–168. Clarendon Press, 1994.

[2] Nate Foster, Dexter Kozen, Konstantinos Mamouras, Mark Reitblatt, andAlexandra Silva. Probabilistic NetKAT. In ESOP, pages 282–309, April2016.

[3] P. R. Halmos. Measure Theory. Van Nostrand, 1950.

[4] Claire Jones. Probabilistic Non-determinism. PhD thesis, University ofEdinburgh, August 1989.

[5] A. N. Kolmogorov and S. V. Fomin. Introductory Real Analysis. PrenticeHall, 1970.

[6] M. M. Rao. Measure Theory and Integration. Wiley-Interscience, 1987.

[7] N. Saheb-Djahromi. CPOs of measures for nondeterminism. TheoreticalComputer Science, 12:19–37, 1980.

A Questions

Let O be the monotone class generated by O; that is, the smallest class ofsets containing O and closed under union of countable ascending chains andintersection of countable descending chains. Every element of O is Borel, butthere are Borel sets not in O, as every element of O is up-closed.

Lemma 32. µ v ν iff µ(B) ≤ ν(B) for all B ∈ O.

Proof. If B0 ⊆ B1 ⊆ B2 ⊆ · · · and µ(Bn) ≤ ν(Bn) for all n, then

µ(⋃n

Bn) = supnµ(Bn) ≤ sup

nν(Bn) = ν(

⋃n

Bn).

28

Page 29: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Similarly, if B0 ⊇ B1 ⊇ B2 ⊇ · · · and µ(Bn) ≤ ν(Bn) for all n, then

µ(⋂n

Bn) = infnµ(Bn) ≤ inf

nν(Bn) = ν(

⋂n

Bn).

Conjecture 1. µ v ν iff µ(B) ≤ ν(B) for all up-closed sets B ∈ B.

Proof. Surely (⇐) holds, since every element of O is up-closed. Converse?

Conjecture 2. The up-closed sets of B are just O.

Proof. Surely (⊇) holds. Converse?

By Lemma 32, a positive answer to Conjecture 2 would imply a positiveanswer to Conjecture 1. All up-closed sets with a countable set of minimalelements are in O, but this is not all of them:

Lemma 33. There is an element of O with no countable set of minimal elements.

Proof. Let An be the subset of 2H described by the characteristic strings

(1(0 + 1) + (0 + 1)1)n(0 + 1)ω.

Then An is up-closed and its minimal elements are the antichain (10 + 01)n0ω.This is a finite set of minimal elements for An, thus An ∈ O. Note also thatAn+1 ⊆ An, since

(10 + 01)n+10ω = (10 + 01)n(10 + 01)0ω

≥ (10 + 01)n(00 + 00)0ω = (10 + 01)n0ω.

The intersection of the An is (1(0 + 1) + (0 + 1)1)ω with uncountably manyminimal elements (10 + 01)ω.

Using Lemma 33, it follows from a cardinality argument that there existup-closed non-Borel sets. However, it is more difficult to show that there existup-closed non-Lebesgue measurable sets. The Lebesgue measurable sets arethe completion of the Borel sets by nullsets. A construction of an up-closednon-Lebesgue measurable set is given in Appendix B.

B An Up-closed Non-Lebesgue Measurable Set

Define λ(Aab) = 2−|b| for b ∈ ℘ω(H). By Theorem 1, λ extends uniquely to ameasure on B, called the uniform or Lebesgue measure on 2H. A set is a nullsetif it is a subset of a Borel set of Lebesgue measure 0. The Lebesgue measurable

29

Page 30: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

sets are the smallest σ-algebra containing the Borel sets and the nullsets. A setis Lebesgue measurable iff it differs from a Borel set by a nullset; that is, iff thereexists a Borel set B such that A⊕B is a nullset, where ⊕ denotes the symmetricdifference operator on sets [3, Theorem 13.B]. The measure λ extends uniquelyto all Lebesgue measurable sets by assigning λ(N) = 0 for all nullsets N .

For c ∈ 2H, define the map Tc : 22H → 22H

by Tc(B) = {a⊕ c | a ∈ B}.

Lemma 34.

(i) Tc is an involution.

(ii) For b ∈ 2H finite and a ⊆ b, Tc(Aab) = Aa⊕(b∩c),b.

(iii) Tc preserves the Borel sets and Lebesgue measurable sets.

(iv) Lebesgue measure is invariant under Tc.

Proof. (iv) In light of the definition of λ on atoms Aab, this is immediate from(ii) and Theorem 1.

Lemma 35 ([3, Theorem 16.A]). For any nonnull Lebesgue measurable set Band for all ε > 0, there exists a basic Cantor open set Aab such that λ(Aab ∩B)/λ(Aab) ≥ 1− ε.

Proof. The Cantor space 2H is a Polish space, therefore outer regular. Thismeans that for any probability measure µ, any Borel set is approximated inmeasure arbitrarily closely from above by Cantor open sets; that is, for anyBorel set B and ε > 0 there exists a Cantor open set A such that B ⊆ A andµ(A−B) ≤ ε.

Suppose λ(B) > 0. For ε > 0, let A be a Cantor open set such that B ⊆ Aand

λ(A−B) < ε · λ(B) ≤ ε · λ(A). (B.1)

The Cantor open set A can be represented as a countable disjoint union of basicCantor open sets Aab. For each point c ∈ A, let Aab be a maximal Cantorbasic open set such that c ∈ Aab ⊆ A. These sets exist by Lemma 3. Thecollection of all such sets is the desired countable disjoint union A =

⋃nAn. If

all λ(An −B) ≥ ε · λ(An), then

λ(A−B) = λ(⋃n

An −B) =∑n

λ(An −B)

≥∑n

ε · λ(An) = ε · λ(⋃n

An) = ε · λ(A),

contradicting (B.1). Thus λ(An − B) < ε · λ(An) for some n, from which theresult for Borel sets B follows.

30

Page 31: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

For a Lebesgue measurable set C, let B be a Borel set such that B ⊕C ⊆ D,where D is Borel and λ(D) = 0. Approximate the Borel set B ∪D from abovewith a Cantor basic open set A. As

B −D ⊆ C ⊆ B ∪D (B ∪D)− (B −D) ⊆ D,

we have

λ(A− C) ≤ λ(A− (B −D))

= λ(A− (B ∪D)) + λ((B ∪D)− (B −D))

≤ λ(A− (B ∪D)) + λ(D)

≤ λ(A− (B ∪D))

≤ ε · λ(A).

A filter on 2H is a nonempty subset of 2H that is up-closed, closed underfinite intersection, and does not contain ∅. A filter is an ultrafilter if, whenevera ∪ b ∈ F , either a ∈ F or b ∈ F . An ultrafilter is principal if it is of the form{a}↑ for some a ∈ 2H, nonprincipal otherwise. An ultrafilter is nonprincipal iffit contains no finite sets. Nonprincipal ultrafilters can be constructed from thecofinite sets by Zorn’s lemma.

Lemma 36. If c is finite and U is a nonprincipal ultrafilter, then Tc(U) = U .

Proof. If a ∈ U and c is finite, then ∼c is cofinite, therefore ∼c ∈ U . Since U isclosed under intersection, a−c ∈ U . Since U is up-closed, a⊕c = (a−c)∪(c−a) ∈U . Since a ∈ U was arbitrary, we have shown that Tc(U) ⊆ U . Since Tc is aninvolution, by monotonicity we also have U = Tc(Tc(U)) ⊆ Tc(U), thereforeTc(U) = U .

Theorem 12. There exists an up-closed non-Lebesgue measurable set.

Proof. Let U be a nonprincipal ultrafilter on 2H. Then U is up-closed. We claimthat U is not Lebesgue measurable. Suppose it were. By Lemma 35, if λ(U) > 0,then there is a Cantor basic open set Aab such that λ(Aab ∩ U)/λ(Aab) ≥ 1− ε.Applying Tc for c ⊆ b, we have

λ(Aab ∩ U) = λ(Tc(Aab ∩ U)) = λ(Tc(Aab) ∩ Tc(U)) = λ(Aa⊕c,b ∩ U),

thus λ(Acb ∩ U) = λ(Aab ∩ U) for all c ⊆ b. Summing over all atoms of Bb,

λ(U) = λ(⋃c⊆b

Acb ∩ U) =∑c⊆b

λ(Acb ∩ U) = 2|b| · λ(Aab ∩ U)

≥ 2|b| · (1− ε) · λ(Aab) = 2|b| · (1− ε) · 2−|b| = 1− ε.

As ε > 0 was arbitrary, λ(U) = 1.

31

Page 32: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

We have argued that if λ(U) > 0, then λ(U) = 1. Thus either λ(U) = 0 orλ(U) = 1. But both are impossible, because

TH(U) = {H ⊕ a | a ∈ U} = {∼a | a ∈ U} = 2H ⊕ U = 2H − U,

since for all a ∈ 2H, a ∈ U iff ∼a 6∈ U ; so by Lemma 36,

λ(U) = λ(TH(U)) = λ(2H − U) = 1− λ(U),

thus λ(U) = 1/2. This is a contradiction.

C M,v is not an Upper Semilattice

Despite the fact that (M,v) is a directed set (Lemma 9), it is not an uppersemilattice. Here is a counterexample.

Let b = {π, σ, τ}, where π, σ, τ are distinct packets. Let

µ1 = 12δ{π} + 1

2δ{σ} µ2 = 12δ{σ} + 1

2δ{τ} µ3 = 12δ{τ} + 1

2δ{π}.

The measures µ1, µ2, and µ3 would be the output measures of the programsπ!⊕ σ!, σ!⊕ τ !, and τ !⊕ π!, respectively.

We claim that µ1 t µ2 does not exist. To see this, define

ν1 = 12δ{τ} + 1

2δ{π,σ} ν2 = 12δ{π} + 1

2δ{σ,τ} ν3 = 12δ{σ} + 1

2δ{τ,π}.

All νi are v-upper bounds for all µj . (In fact, any convex combination rν1 +sν2 + tν3 for 0 ≤ r, s, t and r + s + t = 1 is an upper bound for any convexcombination uµ1 + vµ2 + wµ3 for 0 ≤ u, v, w and u+ v + w = 1.) But we showby contradiction that there cannot exist a measure that is both v-above µ1 andµ2 and v-below ν1 and ν2. Suppose ρ was such a measure. Since ρ v ν1 andρ v ν2, we have

ρ(Bστ ) ≤ ν1(Bστ ) = 0 ρ(Bτπ) ≤ ν1(Bτπ) = 0 ρ(Bπσ) ≤ ν2(Bπσ) = 0.

Since µ1 v ρ and µ2 v ρ, we have

ρ(Bπ) ≥ µ1(Bπ) = 12 ρ(Bσ) ≥ µ1(Bσ) = 1

2 ρ(Bτ ) ≥ µ2(Bτ ) = 12 .

But then

ρ(Aπb) = ρ(Bπ)− ρ(Bπσ ∪Bτπ) ≥ 12

ρ(Aσb) = ρ(Bσ)− ρ(Bστ ∪Bπσ) ≥ 12

ρ(Aτb) = ρ(Bτ )− ρ(Bτπ ∪Bστ ) ≥ 12 ,

which is impossible, because ρ would have total weight at least 32 .

32

Page 33: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

D Negative Attempts of Approximation

Given a sequence of sets X1, X2, . . . , we write Xi ↑ X whenever X1 ⊆ X2 ⊆ . . .and

⋃i∈NXi = X; and we write Xi ↓ X whenever X1 ⊇ X2 ⊇ . . . and⋂

i∈NXi = X.

Fix an arbitrary sequence of finite history sets bi ∈ ℘ω(H) such that bi ↑ H.We investigate the ability of the boolean subalgebras Bbi of B to approximatemeasurable sets A ∈ B.

Lemma 37. Let b ⊆ H and h∗ ∈ H− b. Then all events A ∈ Bb are indifferentwith respect to h∗, that is for all history sets a ⊆ H, it holds that

a ∈ A ⇐⇒ a ∪ {h∗} ∈ A (D.1)

Proof. It suffices to show the claim for all events Bh with h ∈ b since they generatethe boolean algebra Bb and since (D.1) is preserved by union, intersection, andnegation of events.

Recall that a set is in Bh iff it contains the history h. If a contains h thencleary a ∪ {h∗} also contains h. Conversely, if a ∪ {h∗} contains h then a mustcontain h, because by assumption h ∈ b and h∗ 6∈ b, that is h 6= h∗.

Lemma 38. Not all up-closed, measurable sets A ∈ B can be approximated frombelow by sets Ai ∈ Bbi in the sense that Ai ↑ A.

Proof. Consider an infinite sets of histories a ⊆ H and take A , Ba to be theset of all its supersets, an up-closed, measurable set. Now suppose we hada sequence of events Ai ∈ Bbi with Ai ⊆ A. Recall that the bi are finite byassumption – hence we can pick a history h∗i ∈ a− bi for each i such that, byLemma 37, all events in Bbi are indifferent with respect to h∗i . But this meansthat Ai must be empty, for if there existed a history set ai ∈ Ai, we would alsohave ai − {h∗i } ∈ Ai (D.1), contradicting the assumption that Ai ⊆ A. But if allAi are empty, we do not have Ai ↑ A.

Lemma 39. Not all up-closed, measurable sets A ∈ B can be approximated fromabove by sets Ai ∈ Bbi in the sense that Ai ↓ A.

Proof. Let c , {πn ∈ H | n > 0} denote the set of all histories build from asingle packet π. For each finite history set b, let hb denote a history that is notin c ∪ b – since b is finite, such a history always exists. Define a “fake” c for anyb by cb , (c ∩ b) ] hb. Finally, define the measurable set A ,

⋃b finiteBcb , the

smallest upward closed set containing all fakes. Observe that the “real” c is notin A.

Unfortunately, the boolean algebras Bbi fail to discriminate between c andits fakes. In particular, for any bi, the atom Ac∩bi,bi contains both the fake cbiand the real c. Therefore we must have Ai ⊇ Ac∩bi,bi , and as a result c ∈ Ai. Itfollows that

⋂iAi 6= A, since A does not contain c.

33

Page 34: Order-Theoretic Semantics for ProbNetKAT · D!Eform a DCPO. This space is denoted [D!E]. (vi) In an algebraic DCPO, the open sets fag"for nite aform a base for the Scott topology.

Non-Theorem 1. Let f : 2H → R be a measurable function that is monotonewith respect to the subset order on 2H (that is, a ⊆ b⇒ f(a) ≤ f(b)), and let µbe a probability measure on (2H,B). Then∫

c∈2H

f(c) · µ(dc) = infb finite

∑a⊆b

supc∈Aab

f(c) · µ(Aab)

Counterexample. Let c , {πn ∈ H | n > 0} denote the set of all histories buildfrom a single packet π. For each finite history set b, let hb denote a history thatis not in c ∪ b – since b is finite, such a history always exists. Define a “fake” cfor any b by cb , (c∩ b)]hb. Finally, define the measurable set S ,

⋃b finiteBcb ,

the smallest upward closed set containing all fakes. Observe that the “real” c isnot in S.

We now consider the characteristic function f , 1S of S together with thedirac measure µ , δc on c. Since S is upward-closed, f is monotone as required.Because c 6∈ S, we have ∫

fdµ = µ(S) = 0

Unfortunately, the boolean algebras Bb fail to discriminate between c and itsfakes. In particular, for any finite b, the atom Ac∩b,b contains both c and thefake cb; as a result,∑

a⊆b

supd∈Aab

f(d) · µ(Aab) ≥ supd∈Ac∩b,b

f(d) · µ(Ac∩b,b) = 1

and therefore

infb finite

∑a⊆b

supd∈Aab

f(d) · µ(Aab) ≥ 1 >

∫fdµ = 0

E Non-Algebraicity

Here is a counterexample to the conjecture that the elements continuous DCPOof continuous kernels is algebraic with finite elements b ; P ; d. Let σ, τ bepackets and let σ! and τ ! be the programs that set the current packet to σ or τ ,respectively. For r ∈ [ 1

2 , 1], let Pr = (σ! ⊕r τ !) & (τ ! ⊕r σ!). On any nonemptyinput, Pr produces {σ} with probability r(1− r), {τ} with probability r(1− r),and {σ, τ} with probability r2 + (1 − r)2. In particular, P1 produces {σ, τ}with probability 1. The kernels Pr for 1/2 ≤ r < 1 form a directed set whosesupremum is P1, yet {σ} ; P1 ; {σ, τ} is not v-bounded by any Pr for r < 1,therefore the up-closure of {σ} ; P1 ; {σ, τ} is not an open set.

34